Currently, the next blocks that need to be downloaded are determined in blockchain and returned via a new slice by using a lookahead method along with allowing the caller to specify a map of blocks to exclude for the blocks that have already been requested. While this method works fine for a single peer, it does not lend itself well to parallel block downloads. Further, the lookahead mechanism imposes an artificial limit on the number of outstanding requests which is not something that it should be concerned with and it also is not particularly efficient since it results in new allocations every time it is queried. Consequently, this reworks the logic such that the function in blockchain accepts a backing array from the caller that is populated via an allocation-free windowing mechanism and the sync manager now maintains that array along with additional logic to detect when to update it. Not only is the new approach quite a bit more efficient, it removes the artificial limits on outstanding requests so they can be tuned as needed by the sync manager. |
||
|---|---|---|
| .. | ||
| doc.go | ||
| interface.go | ||
| log.go | ||
| manager.go | ||
| README.md | ||
netsync
Package netsync implements a concurrency safe block syncing protocol.
Overview
The provided implementation of SyncManager communicates with connected peers to perform an initial block download, keep the chain in sync, and announce new blocks connected to the chain. Currently the sync manager selects a single sync peer that it downloads all blocks from until it is up to date with the longest chain the sync peer is aware of.
License
Package netsync is licensed under the copyfree ISC License.