Interface ChainSyncer
- All Known Implementing Classes:
SyncManager
Defined in blockchain-core so that
BlockchainNode can trigger chain sync on
startup without a hard dependency on the blockchain-network module
(design.md §7.1 — dependency inversion principle).
The concrete SyncManager implementation in blockchain-network
broadcasts a GET_STATUS message to all connected peers, identifies the
peer with the highest chain, fetches missing blocks, validates each one via the
configured ConsensusEngine, and appends them
via Blockchain.addBlock(com.privatechain.core.model.Block)
(design.md §4.3 — peer sync flow).
- Since:
- 1.0.0
- See Also:
-
Method Summary
-
Method Details
-
syncChain
int syncChain()Synchronizes the local chain with the network.Fetches and applies all blocks that the local node is missing, starting from
localChainHeight + 1up to the canonical chain height reported by the best peer. Returns0if the local chain is already up-to-date.- Returns:
- the number of blocks appended during this sync operation (≥ 0)
-