mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 03:27:58 +00:00
Don't call runtime if pool is empty. (#1283)
This commit is contained in:
committed by
Svyatoslav Nikolsky
parent
0c32567c1c
commit
eba9d1e0a4
@@ -196,6 +196,11 @@ impl<C: Components> MaintainTransactionPool<Self> for C where
|
||||
) -> error::Result<()> {
|
||||
use runtime_primitives::transaction_validity::TransactionValidity;
|
||||
|
||||
// Avoid calling into runtime if there is nothing to prune from the pool anyway.
|
||||
if transaction_pool.status().is_empty() {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
let block = client.block(id)?;
|
||||
let tags = match block {
|
||||
None => return Ok(()),
|
||||
@@ -222,7 +227,6 @@ impl<C: Components> MaintainTransactionPool<Self> for C where
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The super trait that combines all required traits a `Service` needs to implement.
|
||||
pub trait ServiceTrait<C: Components>:
|
||||
Deref<Target = Service<C>>
|
||||
|
||||
@@ -294,6 +294,13 @@ pub struct Status {
|
||||
pub future: usize,
|
||||
}
|
||||
|
||||
impl Status {
|
||||
/// Returns true if the are no transactions in the pool.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.ready == 0 && self.future == 0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user