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