github.com/koko1123/flow-go-1@v0.29.6/module/mempool/chunk_statuses.go (about)

     1  package mempool
     2  
     3  import (
     4  	"github.com/koko1123/flow-go-1/model/flow"
     5  	"github.com/koko1123/flow-go-1/model/verification"
     6  )
     7  
     8  // ChunkStatuses is an in-memory storage for maintaining the chunk status data objects.
     9  type ChunkStatuses interface {
    10  	// Get returns a chunk status by its chunk index and result ID.
    11  	// There is a one-to-one correspondence between the chunk statuses in memory, and
    12  	// their pair of chunk index and result id.
    13  	Get(chunkIndex uint64, resultID flow.Identifier) (*verification.ChunkStatus, bool)
    14  
    15  	// Add provides insertion functionality into the memory pool.
    16  	// The insertion is only successful if there is no duplicate status with the same
    17  	// chunk ID in the memory. Otherwise, it aborts the insertion and returns false.
    18  	Add(status *verification.ChunkStatus) bool
    19  
    20  	// Remove provides deletion functionality from the memory pool based on the pair of
    21  	// chunk index and result id.
    22  	// If there is a chunk status associated with this pair, Remove removes it and returns true.
    23  	// Otherwise, it returns false.
    24  	Remove(chunkIndex uint64, resultID flow.Identifier) bool
    25  
    26  	// All returns all chunk statuses stored in this memory pool.
    27  	All() []*verification.ChunkStatus
    28  
    29  	// Size returns total number of chunk statuses in the memory pool.
    30  	Size() uint
    31  }