Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add address priority queue #210

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_front(&mut self) -> ThinTransaction {
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)
}
}
Loading