github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/mempool/collections.go (about)

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