mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 02:21:14 +00:00
Prepare for asynchronous transaction validation in tx pool (#3650)
* async txpool API * Update core/rpc/src/author/mod.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update core/transaction-pool/graph/src/pool.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Pool -> Pool + ValidatedPool * removed lost block_on when importing xt from network * fix grumbles * alias for future::Executor in rpc * removed executor from Author RPCs * Pool + SharedValidatedPool -> Pool * fix compilation after merge * another fix * another fix
This commit is contained in:
committed by
GitHub
parent
facf31f77e
commit
387c31598d
@@ -302,29 +302,28 @@ impl<A: ChainApi> AsyncApi<A> {
|
||||
match msg {
|
||||
ExtMessage::SubmitExtrinsic(ext) => self.submit_extrinsic(ext),
|
||||
}
|
||||
future::ready(())
|
||||
});
|
||||
|
||||
future::join(extrinsics, http)
|
||||
.map(|((), ())| ())
|
||||
}
|
||||
|
||||
fn submit_extrinsic(&mut self, ext: Vec<u8>) {
|
||||
fn submit_extrinsic(&mut self, ext: Vec<u8>) -> impl Future<Output = ()> {
|
||||
let xt = match <A::Block as traits::Block>::Extrinsic::decode(&mut &*ext) {
|
||||
Ok(xt) => xt,
|
||||
Err(e) => {
|
||||
warn!("Unable to decode extrinsic: {:?}: {}", ext, e.what());
|
||||
return
|
||||
return future::Either::Left(future::ready(()))
|
||||
},
|
||||
};
|
||||
|
||||
info!("Submitting to the pool: {:?} (isSigned: {:?})", xt, xt.is_signed());
|
||||
match self.transaction_pool.submit_one(&self.at, xt.clone()) {
|
||||
Ok(hash) => debug!("[{:?}] Offchain transaction added to the pool.", hash),
|
||||
Err(e) => {
|
||||
debug!("Couldn't submit transaction: {:?}", e);
|
||||
},
|
||||
}
|
||||
future::Either::Right(self.transaction_pool
|
||||
.submit_one(&self.at, xt.clone())
|
||||
.map(|result| match result {
|
||||
Ok(hash) => { debug!("[{:?}] Offchain transaction added to the pool.", hash); },
|
||||
Err(e) => { debug!("Couldn't submit transaction: {:?}", e); },
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +353,7 @@ mod tests {
|
||||
let db = LocalStorage::new_test();
|
||||
let client = Arc::new(test_client::new());
|
||||
let pool = Arc::new(
|
||||
Pool::new(Default::default(), transaction_pool::ChainApi::new(client.clone()))
|
||||
Pool::new(Default::default(), transaction_pool::FullChainApi::new(client.clone()))
|
||||
);
|
||||
|
||||
let mock = Arc::new(MockNetworkStateInfo());
|
||||
|
||||
Reference in New Issue
Block a user