Parallel Block Downloads
New network protocol & strategy.
- Achieve parallel downloads of chain
- Introduce framework that can form basis of Swarm
- Minimise unnecessary block transfers
- Two peers connect & say Hello. Hello includes the TD & hash of their best block.
- The client with the worst TD asks peer for full chain of just block hashes.
- Chain of hashes is stored in space shared by all peer connections, and used as a "work pool".
- While there are hashes in the chain of hashes that we don't have in our chain:
- Ask for N blocks from our peer using the hashes. Mark them as on their way so we don't get them from another peer.
Network protocol: 33
Additional parameters to Hello:
TD: Total Difficulty of the best chain. Integer.
BestHash: The hash of the best (i.e. highest TD) known block.
GenesisHash: The hash of the Genesis block.
Additional Message types:
P]: Requests a
BlockHashesmessage of at most
maxBlocksentries, of block hashes from the blockchain, starting at the parent of block
hash. Does not require the peer to give
maxBlockshashes - they could give somewhat fewer.
B_32, .... ]: Gives a series of hashes of blocks (each the child of the next). This implies that the blocks are ordered from youngest to oldest.
B_32, .... ]: Requests a
Blocksmessage detailing a number of blocks to be sent, each referred to by a hash. Note: Don't expect that the peer necessarily give you all these blocks in a single message - you might have to re-request them.
Remove Message types: