btcd/netsync
Boris Nagaev 0860e42dcf
netsync: avoid clock tick race in sync state test
TestSyncStateMachine checked that handleHeadersMsg advanced
lastProgressTime by comparing it against the timestamp written by
startSync. Those two writes can happen within the same clock tick, so
the handler can update the field while time.After still reports false.

Reset lastProgressTime to the zero value before delivering headers and
assert that the handler writes a non-zero value. This keeps the test
focused on the behavior under test without depending on adjacent
time.Now calls producing distinct timestamps.
2026-07-02 01:18:38 -05: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: require block-serving services on regtest/simnet sync peers 2026-06-17 13:45:43 +02:00
manager_test.go netsync: avoid clock tick race in sync state test 2026-07-02 01:18:38 -05: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.