Documentation
¶
Index ¶
- type Item
- type Mempool
- func (th *Mempool[T]) Add(ctx context.Context, items []T)
- func (th *Mempool[T]) Build(ctx context.Context, ...) error
- func (th *Mempool[T]) Has(ctx context.Context, itemID ids.ID) bool
- func (th *Mempool[T]) Len(ctx context.Context) int
- func (th *Mempool[T]) PeekMax(ctx context.Context) (T, bool)
- func (th *Mempool[T]) PeekMin(ctx context.Context) (T, bool)
- func (th *Mempool[T]) PopMax(ctx context.Context) (T, bool)
- func (th *Mempool[T]) PopMin(ctx context.Context) (T, bool)
- func (th *Mempool[T]) Remove(ctx context.Context, items []T)
- func (th *Mempool[T]) RemoveAccount(ctx context.Context, sender string)
- func (th *Mempool[T]) SetMinTimestamp(ctx context.Context, t int64) []T
- type SortedMempool
- func (sm *SortedMempool[T]) Add(item T)
- func (sm *SortedMempool[T]) Has(item ids.ID) bool
- func (sm *SortedMempool[T]) Len() int
- func (sm *SortedMempool[T]) PeekMax() (T, bool)
- func (sm *SortedMempool[T]) PeekMin() (T, bool)
- func (sm *SortedMempool[T]) PopMax() (T, bool)
- func (sm *SortedMempool[T]) PopMin() (T, bool)
- func (sm *SortedMempool[T]) Remove(id ids.ID)
- func (sm *SortedMempool[T]) SetMinVal(val uint64) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mempool ¶
type Mempool[T Item] struct { // contains filtered or unexported fields }
func New ¶
func New[T Item]( tracer trace.Tracer, maxSize int, maxPayerSize int, exemptPayers [][]byte, ) *Mempool[T]
New creates a new Mempool. [maxSize] must be > 0 or else the implementation may panic.
func (*Mempool[T]) Add ¶
Add pushes all new items from [items] to th. Does not add a item if the item payer is not exempt and their items in the mempool exceed th.maxPayerSize. If the size of th exceeds th.maxSize, Add pops the lowest value item from th.pm.
func (*Mempool[T]) PeekMax ¶
PeekMax returns the highest valued item in th.pm. Assumes there is non-zero items in Mempool
func (*Mempool[T]) PeekMin ¶
PeekMin returns the lowest valued item in th.pm. Assumes there is non-zero items in Mempool
func (*Mempool[T]) PopMax ¶
PopMax removes and returns the highest valued item in th.pm. Assumes there is non-zero items in Mempool
func (*Mempool[T]) PopMin ¶
PopMin removes and returns the lowest valued item in th.pm. Assumes there is non-zero items in Mempool
func (*Mempool[T]) RemoveAccount ¶
RemoveAccount removes all items by [sender] from th.
type SortedMempool ¶
type SortedMempool[T Item] struct { // GetValue informs heaps how to get the an entry's value for ordering. GetValue func(item T) uint64 // contains filtered or unexported fields }
SortedMempool contains a max-heap and min-heap. The order within each heap is determined by using GetValue.
func NewSortedMempool ¶
func NewSortedMempool[T Item](items int, f func(item T) uint64) *SortedMempool[T]
NewSortedMempool returns an instance of SortedMempool with minHeap and maxHeap containing [items] and prioritized with [f]
func (*SortedMempool[T]) Has ¶
func (sm *SortedMempool[T]) Has(item ids.ID) bool
Has returns if [item] is in sm.
func (*SortedMempool[T]) Len ¶
func (sm *SortedMempool[T]) Len() int
Len returns the number of elements in sm.
func (*SortedMempool[T]) PeekMax ¶
func (sm *SortedMempool[T]) PeekMax() (T, bool)
PopMin returms the maximum value in sm.
func (*SortedMempool[T]) PeekMin ¶
func (sm *SortedMempool[T]) PeekMin() (T, bool)
PeekMin returns the minimum value in sm.
func (*SortedMempool[T]) PopMax ¶
func (sm *SortedMempool[T]) PopMax() (T, bool)
PopMin removes the maximum value in sm.
func (*SortedMempool[T]) PopMin ¶
func (sm *SortedMempool[T]) PopMin() (T, bool)
PopMin removes the minimum value in sm.
func (*SortedMempool[T]) Remove ¶
func (sm *SortedMempool[T]) Remove(id ids.ID)
Remove removes [id] from sm. If the id does not exist, Remove returns.
func (*SortedMempool[T]) SetMinVal ¶
func (sm *SortedMempool[T]) SetMinVal(val uint64) []T
SetMinVal removes all elements in sm with a value less than [val]. Returns the list of removed elements. TDOD: add lock to prevent concurrent access