-
Notifications
You must be signed in to change notification settings - Fork 178
/
chunk_statuses.go
31 lines (25 loc) · 1.24 KB
/
chunk_statuses.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
package mempool
import (
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/verification"
)
// ChunkStatuses is an in-memory storage for maintaining the chunk status data objects.
type ChunkStatuses interface {
// Get returns a chunk status by its chunk index and result ID.
// There is a one-to-one correspondence between the chunk statuses in memory, and
// their pair of chunk index and result id.
Get(chunkIndex uint64, resultID flow.Identifier) (*verification.ChunkStatus, bool)
// Add provides insertion functionality into the memory pool.
// The insertion is only successful if there is no duplicate status with the same
// chunk ID in the memory. Otherwise, it aborts the insertion and returns false.
Add(status *verification.ChunkStatus) bool
// Remove provides deletion functionality from the memory pool based on the pair of
// chunk index and result id.
// If there is a chunk status associated with this pair, Remove removes it and returns true.
// Otherwise, it returns false.
Remove(chunkIndex uint64, resultID flow.Identifier) bool
// All returns all chunk statuses stored in this memory pool.
All() []*verification.ChunkStatus
// Size returns total number of chunk statuses in the memory pool.
Size() uint
}