-
Notifications
You must be signed in to change notification settings - Fork 175
/
approvals.go
31 lines (22 loc) · 1018 Bytes
/
approvals.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
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
package mempool
import (
"github.com/onflow/flow-go/model/flow"
)
// Approvals represents a concurrency-safe memory pool for result approvals.
type Approvals interface {
// Add will add the given result approval to the memory pool. It will return
// false if it was already in the mempool.
Add(approval *flow.ResultApproval) (bool, error)
// RemApproval removes a specific approval.
RemApproval(approval *flow.ResultApproval) (bool, error)
// Rem will attempt to remove all the approvals associated with a chunk.
RemChunk(resultID flow.Identifier, chunkIndex uint64) (bool, error)
// ByChunk returns all the approvals associated with a chunk. It returns an
// empty map if there is nothing.
ByChunk(resultID flow.Identifier, chunkIndex uint64) map[flow.Identifier]*flow.ResultApproval
// All will return a list of all approvals in the memory pool.
All() []*flow.ResultApproval
// Size will return the current size of the memory pool.
Size() uint
}