mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-01 05:27:23 +00:00
prune finalized transactions from the pool
This commit is contained in:
@@ -20,7 +20,7 @@ use std::vec::Vec;
|
||||
use codec::{Joiner, Slicable};
|
||||
use state_machine::{self, CodeExecutor};
|
||||
use primitives::{Header, Block};
|
||||
use primitives::block::{Id as BlockId, Transaction};
|
||||
use primitives::block::{Id as BlockId, Extrinsic};
|
||||
use {backend, error, Client};
|
||||
use triehash::ordered_trie_root;
|
||||
|
||||
@@ -31,7 +31,7 @@ pub struct BlockBuilder<B, E> where
|
||||
error::Error: From<<<B as backend::Backend>::State as state_machine::backend::Backend>::Error>,
|
||||
{
|
||||
header: Header,
|
||||
transactions: Vec<Transaction>,
|
||||
transactions: Vec<Extrinsic>,
|
||||
executor: E,
|
||||
state: B::State,
|
||||
changes: state_machine::OverlayedChanges,
|
||||
@@ -68,7 +68,7 @@ impl<B, E> BlockBuilder<B, E> where
|
||||
/// Push a transaction onto the block's list of transactions. This will ensure the transaction
|
||||
/// can be validly executed (by executing it); if it is invalid, it'll be returned along with
|
||||
/// the error. Otherwise, it will return a mutable reference to self (in order to chain).
|
||||
pub fn push(&mut self, tx: Transaction) -> error::Result<()> {
|
||||
pub fn push(&mut self, tx: Extrinsic) -> error::Result<()> {
|
||||
let output = state_machine::execute(&self.state, &mut self.changes, &self.executor, "execute_transaction",
|
||||
&vec![].and(&self.header).and(&tx))?;
|
||||
self.header = Header::decode(&mut &output[..]).expect("Header came straight out of runtime so must be valid");
|
||||
|
||||
@@ -453,7 +453,7 @@ mod tests {
|
||||
use codec::Slicable;
|
||||
use keyring::Keyring;
|
||||
use {primitives, genesis};
|
||||
use primitives::block::Transaction as PrimitiveTransaction;
|
||||
use primitives::block::Extrinsic as PrimitiveExtrinsic;
|
||||
use test_runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
|
||||
use test_runtime::{UncheckedTransaction, Transaction};
|
||||
use test_runtime;
|
||||
@@ -559,12 +559,12 @@ mod tests {
|
||||
}
|
||||
|
||||
trait Signable {
|
||||
fn signed(self) -> PrimitiveTransaction;
|
||||
fn signed(self) -> PrimitiveExtrinsic;
|
||||
}
|
||||
impl Signable for Transaction {
|
||||
fn signed(self) -> PrimitiveTransaction {
|
||||
fn signed(self) -> PrimitiveExtrinsic {
|
||||
let signature = Keyring::from_raw_public(self.from.clone()).unwrap().sign(&self.encode());
|
||||
PrimitiveTransaction::decode(&mut UncheckedTransaction { signature, tx: self }.encode().as_ref()).unwrap()
|
||||
PrimitiveExtrinsic::decode(&mut UncheckedTransaction { signature, tx: self }.encode().as_ref()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user