RPC for number of unconfirmed transactions

This commit is contained in:
Tomasz Drwięga
2016-06-21 14:55:25 +02:00
parent 06ba7e258e
commit 7cfb9a2b0b
9 changed files with 169 additions and 101 deletions

View File

@@ -69,6 +69,12 @@ pub trait SigningQueue: Send + Sync {
/// Return copy of all the requests in the queue.
fn requests(&self) -> Vec<TransactionConfirmation>;
/// Returns number of transactions awaiting confirmation.
fn len(&self) -> usize;
/// Returns true if there are no transactions awaiting confirmation.
fn is_empty(&self) -> bool;
}
#[derive(Debug, PartialEq)]
@@ -277,6 +283,16 @@ impl SigningQueue for ConfirmationsQueue {
let queue = self.queue.read().unwrap();
queue.values().map(|token| token.request.clone()).collect()
}
fn len(&self) -> usize {
let queue = self.queue.read().unwrap();
queue.len()
}
fn is_empty(&self) -> bool {
let queue = self.queue.read().unwrap();
queue.is_empty()
}
}