-
Notifications
You must be signed in to change notification settings - Fork 175
/
guarantees.go
38 lines (28 loc) · 1.24 KB
/
guarantees.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
38
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
package mempool
import (
"github.com/onflow/flow-go/model/flow"
)
// Guarantees represents a concurrency-safe memory pool for collection guarantees.
type Guarantees interface {
// Has checks whether the collection guarantee with the given hash is
// currently in the memory pool.
Has(collID flow.Identifier) bool
// Add will add the given collection guarantee to the memory pool. It will
// return false if it was already in the mempool.
Add(guarantee *flow.CollectionGuarantee) bool
// Rem will remove the given collection guarantees from the memory pool; it
// will return true if the collection guarantees was known and removed.
Rem(collID flow.Identifier) bool
// ByID retrieve the collection guarantee with the given ID from the memory
// pool. It will return false if it was not found in the mempool.
ByID(collID flow.Identifier) (*flow.CollectionGuarantee, bool)
// Size will return the current size of the memory pool.
Size() uint
// All will retrieve all collection guarantees that are currently in the memory pool
// as a slice.
All() []*flow.CollectionGuarantee
// Hash will return a fingerprint has representing the contents of the
// entire memory pool.
Hash() flow.Identifier
}