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 6, 2024
1 parent e4e9999 commit 43f428f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crates/mempool/src/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,32 @@ 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()
}

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

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

pub fn contains(&self, tx: &ThinTransaction) -> bool {
self.0.contains(tx)
}
}

0 comments on commit 43f428f

Please sign in to comment.