github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/buffer.go (about) 1 package module 2 3 import ( 4 "github.com/onflow/flow-go/model/cluster" 5 "github.com/onflow/flow-go/model/flow" 6 ) 7 8 // PendingBlockBuffer defines an interface for a cache of pending blocks that 9 // cannot yet be processed because they do not connect to the rest of the chain 10 // state. They are indexed by parent ID to enable processing all of a parent's 11 // children once the parent is received. 12 // Safe for concurrent use. 13 type PendingBlockBuffer interface { 14 Add(block flow.Slashable[*flow.Block]) bool 15 16 ByID(blockID flow.Identifier) (flow.Slashable[*flow.Block], bool) 17 18 ByParentID(parentID flow.Identifier) ([]flow.Slashable[*flow.Block], bool) 19 20 DropForParent(parentID flow.Identifier) 21 22 // PruneByView prunes any pending blocks with views less or equal to the given view. 23 PruneByView(view uint64) 24 25 Size() uint 26 } 27 28 // PendingClusterBlockBuffer is the same thing as PendingBlockBuffer, but for 29 // collection node cluster consensus. 30 // Safe for concurrent use. 31 type PendingClusterBlockBuffer interface { 32 Add(block flow.Slashable[*cluster.Block]) bool 33 34 ByID(blockID flow.Identifier) (flow.Slashable[*cluster.Block], bool) 35 36 ByParentID(parentID flow.Identifier) ([]flow.Slashable[*cluster.Block], bool) 37 38 DropForParent(parentID flow.Identifier) 39 40 // PruneByView prunes any pending cluster blocks with views less or equal to the given view. 41 PruneByView(view uint64) 42 43 Size() uint 44 }