Skip to content

Commit

Permalink
feat: add address priority queue. will be used in mempool, multiple t…
Browse files Browse the repository at this point in the history
…xs per account
  • Loading branch information
ayeletstarkware committed Jun 5, 2024
1 parent 4744e13 commit b7c19c8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/mempool/src/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,28 @@ impl PartialOrd for PrioritizedTransaction {
Some(self.cmp(other))
}
}

// TODO: remove when is used.
#[allow(dead_code)]
// Assumption: there are no gaps, and the transactions are received in order.
pub struct AddressPriorityQueue(pub Vec<ThinTransaction>);

// TODO: remove when is used.
#[allow(dead_code)]
impl AddressPriorityQueue {
pub fn push(&mut self, tx: ThinTransaction) {
self.0.push(tx);
}

pub fn top(&self) -> Option<ThinTransaction> {
self.0.first().cloned()
}

pub fn pop(&mut self) -> Option<ThinTransaction> {
Some(self.0.remove(0))
}

pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}

0 comments on commit b7c19c8

Please sign in to comment.