github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/synchronization.go (about)

     1  package module
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/chainsync"
     5  	"github.com/onflow/flow-go/model/flow"
     6  )
     7  
     8  // BlockRequester enables components to request particular blocks by ID from
     9  // synchronization system.
    10  type BlockRequester interface {
    11  
    12  	// RequestBlock indicates that the given block should be queued for retrieval.
    13  	RequestBlock(blockID flow.Identifier, height uint64)
    14  
    15  	// RequestHeight indicates that the given block height should be queued for retrieval.
    16  	RequestHeight(height uint64)
    17  
    18  	// Prune manually prunes requests
    19  	Prune(final *flow.Header)
    20  }
    21  
    22  // SyncCore represents state management for chain state synchronization.
    23  type SyncCore interface {
    24  
    25  	// HandleBlock handles receiving a new block. It returns true if the block
    26  	// should be passed along to the rest of the system for processing, or false
    27  	// if it should be discarded.
    28  	HandleBlock(header *flow.Header) bool
    29  
    30  	// HandleHeight handles receiving a new highest finalized height from another node.
    31  	HandleHeight(final *flow.Header, height uint64)
    32  
    33  	// ScanPending scans all pending block statuses for blocks that should be
    34  	// requested. It apportions requestable items into range and batch requests
    35  	// according to configured maximums, giving precedence to range requests.
    36  	ScanPending(final *flow.Header) ([]chainsync.Range, []chainsync.Batch)
    37  
    38  	// WithinTolerance returns whether or not the given height is within configured
    39  	// height tolerance, wrt the given local finalized header.
    40  	WithinTolerance(final *flow.Header, height uint64) bool
    41  
    42  	// RangeRequested updates sync state after a range is requested.
    43  	RangeRequested(ran chainsync.Range)
    44  
    45  	// BatchRequested updates sync state after a batch is requested.
    46  	BatchRequested(batch chainsync.Batch)
    47  }