dcrd/internal/netsync
Dave Collins 517091c7f6
netsync: Export opaque peer and require it in API.
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.
2023-10-28 01:51:49 -05:00
..
doc.go netsync: Add package documentation. 2020-12-15 13:26:57 -06:00
interface.go netsync/server: Update peer heights directly. 2021-01-07 17:15:36 -06:00
log.go multi: Add chain verify progress percentage. 2021-01-21 23:30:35 -06:00
manager.go netsync: Export opaque peer and require it in API. 2023-10-28 01:51:49 -05:00
README.md netsync: Add package documentation. 2020-12-15 13:26:57 -06:00

netsync

Build Status ISC License Doc

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.