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