andrewvy / opal

Hobby cryptocurrency implementation in C
3 stars 1 forks source link

TODO #1

Open andrewvy opened 7 years ago

andrewvy commented 7 years ago

Needs

transactions

blocks

blockchain

api


Conscious decisions:

andrewvy commented 7 years ago

image

IT'S ALIVE

kinda

empty txless block mining on local (no-net)

andrewvy commented 7 years ago
                                                         ┌──────────────────────────────────────────┐                                                                                      ┌──────────────────────────────────────────┐
                                                         │                                          │                                                                                      │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         │               Opal Daemon                │                                                                                      │                Opal Peer                 │
                                                         │                                          │                                     P2P Layer                                        │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         │                                          │                                                                                      │                                          │
                                                         ├────────────┐                ┌────────────┤                                                                                      │                             ┌────────────┤
                                                         │Internal RPC│                │External RPC│                                                                                      │                             │External RPC│
                                                         │   (9898)   │                │   (9899)   │                                                                                      │                             │   (9899)   │
                                                         └────────────┴────────────────┴────────────┘                                                                                      └─────────────────────────────┴────────────┘
                                                                │                             │                                                                                                                                 ▲      
                                                                │                             │                                                                                                                                 │      
                                                                │                             ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘      
                                                                │                             │ Protobuf over HTTP                                                                                                                     
                                                                │                             │                                                                                            ┌──────────────────────────────────────────┐
                                              Protobuf over HTTP│                             │                                                                                            │                                          │
      Client Agnostic RPC Layer              ┌──────────────────┤                             │                                                                                            │                                          │
                                             │                  │                             │                                                                                            │                                          │
                                             │                  │                             │                                                                                            │                                          │
                                             │                  │                             │                                                                                            │                                          │
                                             │                  │                             │                                                                                            │                                          │
                                             │                  │                             │                                                                                            │                Opal Peer                 │
                                             │                  │                             │                                                                                            │                                          │
                                             ▼                  ▼                             │                                                                                            │                                          │
                                       ┌───────────┐    ┌───────────────┐                     │                                                                                            │                                          │
                                       │Rust Client│    │Built-in Client│                     │                                                                                            │                             ┌────────────┤
                                       └───────────┘    └───────────────┘                     │                                                                                            │                             │External RPC│
                                                                                              │                                                                                            │                             │   (9899)   │
                                                                                              │                                                                                            └─────────────────────────────┴────────────┘
                                                                                              │                                                                                                                                 ▲      
                                                                                              │                                                                                                                                 │      
                                                                                              ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘      
                                                                                              │                                                                                                                                        
                                                                                              │                                                                                            ┌──────────────────────────────────────────┐
                                                                                              │                                                                                            │                                          │
      ┌─────────────────────────┐                                                             │                                                                                            │                                          │
      │ Initialization Sequence │                                                             │                                                                                            │                                          │
      └─────────────────────────┘                                                             │                                                                                            │                                          │
                                                                                              │                                                                                            │                                          │
                                                                                              │                                                                                            │                                          │
      1) Get external facing IP address using UPnP                                            │                                                                                            │                Opal Peer                 │
                                                                                              │                                                                                            │                                          │
      2) Broadcast 'Peer Advertise' message with                                              │                                                                                            │                                          │
      external IP                                                                             │                                                                                            │                                          │
                                                                                              │                                                                                            │                             ┌────────────┤
      3) Call 'Peer List' on seed DNS nodes and keep                                          │                                                                                            │                             │External RPC│
      track in a local list of peers, also saved for                                          │                                                                                            │                             │   (9899)   │
      later peer discovery seed usage.                                                        │                                                                                            └─────────────────────────────┴────────────┘
                                                                                              │                                                                                                                                 ▲      
      4) Start downloading block headers from peers                                           │                                                                                                                                 │      
                                                                                              └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘      
      5) Validate headers and figure out the 'best                                                                                                                                                                                     
      header chain'                                                                                                                                                                                                                    

      6) Once best header chain has been found, start                                                                                                                                                                                  
      downloading full blocks from peers.                                                                                                                                                                                              

      7) Start validating full blocks and maintain a                                                                                                                                                                                   
      UXTO database                                                                                                                                                                                                                    

      8) You are ready to start accepting TXs and                                                                                                                                                                                      
      Blocks!