Currently the sync manager maintains additional state per peer in an internal struct that wraps a base/common peer as well as a mapping keyed by that base/common peer. The internal wrapped peer is then queried each time it is needed. This leads to code that is harder to reason about and can fail to lookup the necessary state in some hard to hit corner cases. With that in mind, this modifies the sync manager semantics to instead export the wrapped peer and require the caller to provide that wrapped peer in all of its APIs directly. The server then creates and stores the wrapped peer instance at connection time and passes it to the sync manager. The end result is the code is easier to reason about and resolves the aforementioned hard to hit corner cases since it is no longer possible for the sync manager to ever have access to a peer without the associated extra state. |
||
|---|---|---|
| .. | ||
| 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.