mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Extrinsic pool (#182)
* Use latest version of txpool. * Initial version of the pool. * Fix abstraction. * Implement watchers and notifications. * Return hash from RPC. * Remove commented code. * Remove client dep. * Fix tests.
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
|
||||
//! Substrate block-author/full-node API.
|
||||
|
||||
use primitives::block::Extrinsic;
|
||||
use std::sync::Arc;
|
||||
use primitives::block::{Extrinsic, ExtrinsicHash};
|
||||
use extrinsic_pool::api::{Error, ExtrinsicPool};
|
||||
|
||||
pub mod error;
|
||||
|
||||
@@ -30,6 +32,20 @@ build_rpc_trait! {
|
||||
pub trait AuthorApi {
|
||||
/// Submit extrinsic for inclusion in block.
|
||||
#[rpc(name = "author_submitExtrinsic")]
|
||||
fn submit_extrinsic(&self, Extrinsic) -> Result<()>;
|
||||
fn submit_extrinsic(&self, Extrinsic) -> Result<ExtrinsicHash>;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AuthorApi for Arc<T> where
|
||||
T: ExtrinsicPool,
|
||||
{
|
||||
fn submit_extrinsic(&self, xt: Extrinsic) -> Result<ExtrinsicHash> {
|
||||
self
|
||||
.submit(vec![xt])
|
||||
.map(|mut res| res.pop().expect("One extrinsic passed; one result back; qed"))
|
||||
.map_err(|e| e.into_pool_error()
|
||||
.map(Into::into)
|
||||
.unwrap_or_else(|e| error::ErrorKind::Verification(Box::new(e)).into())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user