diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index ea195bf840..66a63d3f51 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -221,7 +221,7 @@ pub fn run(args: I, worker: W) -> error::Result<()> where info!("Starting collator"); // TODO [rob]: collation node implementation // This isn't a thing. Different parachains will have their own collator executables and - // maybe link to libpolkadot to get a light-client. + // maybe link to libpolkadot to get a light-client. service::Roles::LIGHT } else if matches.is_present("light") { info!("Starting (light)"); @@ -478,9 +478,9 @@ fn run_until_exit( let ws_address = parse_address("127.0.0.1:9944", "ws-port", matches)?; let handler = || { - let client = (&service as &substrate_service::Service).client(); + let client = substrate_service::Service::client(&service); let chain = rpc::apis::chain::Chain::new(client.clone(), executor.clone()); - let author = rpc::apis::author::Author::new(client.clone(), service.extrinsic_pool()); + let author = rpc::apis::author::Author::new(client.clone(), service.extrinsic_pool(), executor.clone()); rpc::rpc_handler::, _, _, _, _>( client, chain, diff --git a/polkadot/transaction-pool/src/lib.rs b/polkadot/transaction-pool/src/lib.rs index 75a4eb0dac..6d64d39e8d 100644 --- a/polkadot/transaction-pool/src/lib.rs +++ b/polkadot/transaction-pool/src/lib.rs @@ -44,8 +44,13 @@ use std::{ }; use codec::{Decode, Encode}; -use extrinsic_pool::{Pool, Listener, txpool::{self, Readiness, scoring::{Change, Choice}}}; -use extrinsic_pool::api::{ExtrinsicPool, EventStream}; +use extrinsic_pool::{ + api::{ExtrinsicPool, EventStream}, + txpool::{self, Readiness, scoring::{Change, Choice}}, + watcher::Watcher, + Pool, + Listener, +}; use polkadot_api::PolkadotApi; use primitives::{AccountId, BlockId, Hash, Index, UncheckedExtrinsic as FutureProofUncheckedExtrinsic}; use runtime::{Address, UncheckedExtrinsic}; @@ -385,6 +390,8 @@ impl Deref for TransactionPool { } } +// TODO: more general transaction pool, which can handle more kinds of vec-encoded transactions, +// even when runtime is out of date. impl ExtrinsicPool for TransactionPool where A: Send + Sync + 'static, A: PolkadotApi, @@ -392,8 +399,6 @@ impl ExtrinsicPool for Transact type Error = Error; fn submit(&self, block: BlockId, xts: Vec) -> Result> { - // TODO: more general transaction pool, which can handle more kinds of vec-encoded transactions, - // even when runtime is out of date. xts.into_iter() .map(|xt| xt.encode()) .map(|encoded| { @@ -404,6 +409,18 @@ impl ExtrinsicPool for Transact .collect() } + fn submit_and_watch(&self, block: BlockId, xt: FutureProofUncheckedExtrinsic) -> Result> { + let encoded = xt.encode(); + let decoded = UncheckedExtrinsic::decode(&mut &encoded[..]).ok_or(ErrorKind::InvalidExtrinsicFormat)?; + + let verifier = Verifier { + api: &*self.api, + at_block: block, + }; + + self.inner.submit_and_watch(verifier, decoded) + } + fn light_status(&self) -> LightStatus { self.inner.light_status() }