btcd/netsync
Calvin Kim bfb36e52e7 netsync: process inv announcements when no syncPeer is set
handleInvMsg early-returned for any inv from a non-syncPeer whenever
sm.current() was false, with the comment that it prevents fetching a
mass of orphans. That guard assumes a syncPeer is already fetching
blocks; when syncPeer is nil, the assumption breaks down and the
early return becomes a deadlock.

The deadlock is reachable whenever two nodes connect at equal heights:
startSync exits without picking a syncPeer (no peer is "higher"), and
nothing later promotes the freshly-mined blocks the peer announces via
inv. The pre-verack disconnect and sync-race regression tests in
integration/sync_race_test.go fail consistently because of this.

Only skip the inv when we actually have a syncPeer. When syncPeer is
nil, fall through and let the normal request path queue the block --
the inv is the only signal that there are blocks to fetch.
2026-05-30 17:25:51 +09:00
..
testdata netsync: add checkHeadersList 2026-02-26 16:33:47 +09:00
blocklogger.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
doc.go netsync: Change name of blockManager to syncManager. 2017-08-25 13:41:22 -05:00
interface.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
log.go netsync: Use package-local logger. 2017-08-25 13:41:22 -05:00
manager.go netsync: process inv announcements when no syncPeer is set 2026-05-30 17:25:51 +09:00
manager_test.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
README.md docs: update shields 2021-03-05 07:45:19 -05:00

netsync

Build Status ISC License GoDoc

Overview

This package implements a concurrency safe block syncing protocol. The SyncManager communicates with connected peers to perform an initial block download, keep the chain and unconfirmed transaction pool 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.

Installation and Updating

$ go get -u github.com/btcsuite/btcd/netsync

License

Package netsync is licensed under the copyfree ISC License.