Commit 1412f275 authored by Gav Wood's avatar Gav Wood Committed by GitHub
Browse files

Transaction queue integration + submission RPC (#99)

* Implement transaction queue RPC.

* whitespace

* Support without_std env in environmental!  (#110)

* Make environmental crate support without_std env.

* Small doc fixes.

* Remove dead code.
parent 8fe76e8e
......@@ -118,7 +118,7 @@ pub fn run<I, T>(args: I, exit: mpsc::Receiver<()>) -> error::Result<()> where
let rpc_port: u16 = port.parse().expect("Invalid RPC port value specified.");
address.set_port(rpc_port);
}
let handler = rpc::rpc_handler(service.client());
let handler = rpc::rpc_handler(service.client(), service.transaction_pool());
let _server = rpc::start_http(&address, handler)?;
exit.recv().ok();
......@@ -150,6 +150,7 @@ fn default_base_path() -> PathBuf {
&app_info,
).expect("app directories exist on all supported platforms; qed")
}
fn init_logger(pattern: &str) {
let mut builder = env_logger::LogBuilder::new();
// Disable info logging by default for some modules:
......
......@@ -570,9 +570,13 @@ impl<C: PolkadotApi, R: TableRouter> bft::Proposer for Proposer<C, R> {
}
let polkadot_block = block_builder.bake();
info!("Proposing block [number: {}; extrinsics: [{}], parent_hash: {}]", polkadot_block.header.number, polkadot_block.extrinsics.len(), polkadot_block.header.parent_hash);
let substrate_block = Slicable::decode(&mut polkadot_block.encode().as_slice())
.expect("polkadot blocks defined to serialize to substrate blocks correctly; qed");
assert!(evaluate_proposal(&substrate_block, &*self.client, current_timestamp(), &self.parent_hash, &self.parent_id).is_ok());
Ok(substrate_block)
}
......
......@@ -9,6 +9,8 @@ error-chain = "0.11"
polkadot-api = { path = "../api" }
polkadot-primitives = { path = "../primitives" }
polkadot-runtime = { path = "../runtime" }
substrate-client = { path = "../../substrate/client" }
substrate-rpc = { path = "../../substrate/rpc" }
substrate-primitives = { path = "../../substrate/primitives" }
substrate-runtime-primitives = { path = "../../substrate/runtime/primitives" }
substrate-codec = { path = "../../substrate/codec" }
......
......@@ -17,6 +17,7 @@
extern crate ed25519;
extern crate ethereum_types;
extern crate substrate_codec as codec;
extern crate substrate_rpc;
extern crate substrate_primitives as substrate_primitives;
extern crate substrate_runtime_primitives as substrate_runtime_primitives;
extern crate polkadot_runtime as runtime;
......@@ -31,8 +32,10 @@ use std::collections::HashMap;
use std::cmp::Ordering;
use std::sync::Arc;
use codec::Slicable;
use polkadot_api::PolkadotApi;
use primitives::{AccountId, Timestamp};
use substrate_primitives::block::Extrinsic;
use runtime::{Block, UncheckedExtrinsic, TimestampCall, Call};
use substrate_runtime_primitives::traits::Checkable;
use transaction_pool::{Pool, Readiness};
......@@ -371,6 +374,16 @@ impl TransactionPool {
}
}
impl substrate_rpc::author::AsyncAuthorApi for TransactionPool {
fn submit_extrinsic(&mut self, xt: Extrinsic) -> substrate_rpc::author::error::Result<()> {
self.import(xt
.using_encoded(|ref mut s| UncheckedExtrinsic::decode(s))
.ok_or(substrate_rpc::author::error::ErrorKind::InvalidFormat)?)
.map(|_| ())
.map_err(|_| substrate_rpc::author::error::ErrorKind::PoolError.into())
}
}
#[cfg(test)]
mod tests {
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment