-
Notifications
You must be signed in to change notification settings - Fork 178
/
assignments.go
34 lines (26 loc) · 1.17 KB
/
assignments.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
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
package mempool
import (
chunkmodels "github.com/onflow/flow-go/model/chunks"
"github.com/onflow/flow-go/model/flow"
)
// Assignments represents a concurrency-safe memory pool for chunk assignments
type Assignments interface {
// Has checks whether the Assignment with the given hash is currently in
// the memory pool.
Has(assignmentID flow.Identifier) bool
// Add will add the given assignment to the memory pool. It will return
// false if it was already in the mempool.
Add(assignmentFingerprint flow.Identifier, assignment *chunkmodels.Assignment) bool
// Remove will remove the given Assignment from the memory pool; it will
// return true if the Assignment was known and removed.
Remove(assignmentID flow.Identifier) bool
// ByID retrieve the chunk assigment with the given ID from the memory pool.
// It will return false if it was not found in the mempool.
ByID(assignmentID flow.Identifier) (*chunkmodels.Assignment, bool)
// Size will return the current size of the memory pool.
Size() uint
// All will retrieve all Assignments that are currently in the memory pool
// as a slice.
All() []*chunkmodels.Assignment
}