PriorityQueue

Git Source

Author: Matter Labs

The library provides the API to interact with the priority queue container

Order of processing operations from queue - FIFO (Fist in - first out)

Note: security-contact: security@matterlabs.dev

Functions

getFirstUnprocessedPriorityTx

Returns zero if and only if no operations were processed from the queue

function getFirstUnprocessedPriorityTx(Queue storage _queue)
  internal
  view
  returns (uint256);

Returns

NameTypeDescription
<none>uint256Index of the oldest priority operation that wasn't processed yet

getTotalPriorityTxs

function getTotalPriorityTxs(Queue storage _queue)
  internal
  view
  returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of priority operations that were added to the priority queue, including all processed ones

getSize

function getSize(Queue storage _queue) internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of unprocessed priority operations in a priority queue

isEmpty

function isEmpty(Queue storage _queue) internal view returns (bool);

Returns

NameTypeDescription
<none>boolWhether the priority queue contains no operations

pushBack

Add the priority operation to the end of the priority queue

function pushBack(Queue storage _queue, PriorityOperation memory _operation)
  internal;

front

function front(Queue storage _queue)
  internal
  view
  returns (PriorityOperation memory);

Returns

NameTypeDescription
<none>PriorityOperationThe first unprocessed priority operation from the queue

popFront

Remove the first unprocessed priority operation from the queue

function popFront(Queue storage _queue)
  internal
  returns (PriorityOperation memory priorityOperation);

Returns

NameTypeDescription
priorityOperationPriorityOperationthat was popped from the priority queue

Structs

Queue

Container that stores priority operations

struct Queue {
  mapping(uint256 priorityOpId => PriorityOperation priorityOp) data;
  uint256 tail;
  uint256 head;
}

Properties

NameTypeDescription
datamapping(uint256 priorityOpId => PriorityOperation priorityOp)The inner mapping that saves priority operation by its index
tailuint256The pointer to the free slot
headuint256The pointer to the first unprocessed priority operation, equal to the tail if the queue is empty