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

     1  // (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
     2  package mempool
     3  
     4  import (
     5  	chunkmodels "github.com/koko1123/flow-go-1/model/chunks"
     6  	"github.com/koko1123/flow-go-1/model/flow"
     7  )
     8  
     9  // Assignments represents a concurrency-safe memory pool for chunk assignments
    10  type Assignments interface {
    11  
    12  	// Has checks whether the Assignment with the given hash is currently in
    13  	// the memory pool.
    14  	Has(assignmentID flow.Identifier) bool
    15  
    16  	// Add will add the given assignment to the memory pool. It will return
    17  	// false if it was already in the mempool.
    18  	Add(assignmentFingerprint flow.Identifier, assignment *chunkmodels.Assignment) bool
    19  
    20  	// Remove will remove the given Assignment from the memory pool; it will
    21  	// return true if the Assignment was known and removed.
    22  	Remove(assignmentID flow.Identifier) bool
    23  
    24  	// ByID retrieve the chunk assigment with the given ID from the memory pool.
    25  	// It will return false if it was not found in the mempool.
    26  	ByID(assignmentID flow.Identifier) (*chunkmodels.Assignment, bool)
    27  
    28  	// Size will return the current size of the memory pool.
    29  	Size() uint
    30  
    31  	// All will retrieve all Assignments that are currently in the memory pool
    32  	// as a slice.
    33  	All() []*chunkmodels.Assignment
    34  }