mirror of
https://github.com/btcsuite/btcd.git
synced 2026-08-13 12:32:51 +02:00
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. |
||
|---|---|---|
| .. | ||
| testdata | ||
| blocklogger.go | ||
| doc.go | ||
| interface.go | ||
| log.go | ||
| manager.go | ||
| manager_test.go | ||
| README.md | ||
netsync
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.