Interface ChainSyncer

All Known Implementing Classes:
SyncManager

public interface ChainSyncer
Interface for the initial chain synchronization component.

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

    Modifier and Type
    Method
    Description
    int
    Synchronizes the local chain with the network.
  • 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 + 1 up to the canonical chain height reported by the best peer. Returns 0 if the local chain is already up-to-date.

      Returns:
      the number of blocks appended during this sync operation (≥ 0)