mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 04:37:57 +00:00
Revalidation queue for transaction pool (#4781)
* Revalidation queeue. * add docs and license * move test * refactor worker to async/await * address review * fix warnings * update Cargo.lock * move background task to service * use tomusdrw loop * naming * return From::from * add doc comment * add more doc comments * fix merge bug * add doc comment for test function * Update client/transaction-pool/src/testing/pool.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * more review fixes * refactor to allow service keep background tasks from isntantiated subsystems * use const delay * fix fallout * remove fallout * remove already moved test * fix doc test * add valid_at helper Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -32,7 +32,7 @@ use parking_lot::{Mutex, RwLock};
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{self, SaturatedConversion},
|
||||
transaction_validity::TransactionTag as Tag,
|
||||
transaction_validity::{TransactionTag as Tag, ValidTransaction},
|
||||
};
|
||||
use sp_transaction_pool::{error, PoolStatus};
|
||||
use wasm_timer::Instant;
|
||||
@@ -53,6 +53,30 @@ pub enum ValidatedTransaction<Hash, Ex, Error> {
|
||||
Unknown(Hash, Error),
|
||||
}
|
||||
|
||||
impl<Hash, Ex, Error> ValidatedTransaction<Hash, Ex, Error> {
|
||||
/// Consume validity result, transaction data and produce ValidTransaction.
|
||||
pub fn valid_at(
|
||||
at: u64,
|
||||
hash: Hash,
|
||||
data: Ex,
|
||||
bytes: usize,
|
||||
validity: ValidTransaction,
|
||||
) -> Self {
|
||||
Self::Valid(base::Transaction {
|
||||
data,
|
||||
bytes,
|
||||
hash,
|
||||
priority: validity.priority,
|
||||
requires: validity.requires,
|
||||
provides: validity.provides,
|
||||
propagate: validity.propagate,
|
||||
valid_till: at
|
||||
.saturated_into::<u64>()
|
||||
.saturating_add(validity.longevity),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// A type of validated transaction stored in the pool.
|
||||
pub type ValidatedTransactionFor<B> = ValidatedTransaction<
|
||||
ExHash<B>,
|
||||
|
||||
Reference in New Issue
Block a user