github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/mempool/blocks.go (about) 1 package mempool 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 ) 6 7 // Blocks represents a concurrency-safe memory pool for blocks. 8 type Blocks interface { 9 10 // Has checks whether the block with the given hash is currently in 11 // the memory pool. 12 Has(blockID flow.Identifier) bool 13 14 // Add will add the given block to the memory pool. It will return 15 // false if it was already in the mempool. 16 Add(block *flow.Block) bool 17 18 // Remove will remove the given block from the memory pool; it will 19 // will return true if the block was known and removed. 20 Remove(blockID flow.Identifier) bool 21 22 // ByID retrieve the block with the given ID from the memory pool. 23 // It will return false if it was not found in the mempool. 24 ByID(blockID flow.Identifier) (*flow.Block, bool) 25 26 // Size will return the current size of the memory pool. 27 Size() uint 28 29 // All will retrieve all blocks that are currently in the memory pool 30 // as a slice. 31 All() []*flow.Block 32 33 // Hash will return a hash of the contents of the memory pool. 34 Hash() flow.Identifier 35 }