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