Fixed a few authoring issues (#315)

This commit is contained in:
Arkadiy Paronyan
2018-07-14 22:27:25 +02:00
committed by Gav Wood
parent b8216372c7
commit 5b3050293a
18 changed files with 15 additions and 12 deletions
-1
View File
@@ -1580,7 +1580,6 @@ dependencies = [
"slog 2.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-client 0.1.0",
"substrate-codec 0.1.0",
"substrate-keystore 0.1.0",
"substrate-network 0.1.0",
"substrate-primitives 0.1.0",
"substrate-runtime-io 0.1.0",
+2 -2
View File
@@ -335,7 +335,7 @@ mod tests {
fn native_big_block_import_succeeds() {
let mut t = new_test_ext();
let r = Executor::new().call(&mut t, COMPACT_CODE, "execute_block", &block1big().0, true).0;
let r = Executor::with_heap_pages(8).call(&mut t, COMPACT_CODE, "execute_block", &block1big().0, true).0;
assert!(r.is_ok());
}
@@ -343,7 +343,7 @@ mod tests {
fn native_big_block_import_fails_on_fallback() {
let mut t = new_test_ext();
let r = Executor::new().call(&mut t, COMPACT_CODE, "execute_block", &block1big().0, false).0;
let r = Executor::with_heap_pages(8).call(&mut t, COMPACT_CODE, "execute_block", &block1big().0, false).0;
assert!(!r.is_ok());
}
+1 -1
View File
@@ -198,7 +198,7 @@ impl<P: LocalPolkadotApi + Send + Sync + 'static> Future for MessageProcessTask<
return Ok(async);
},
Ok(Async::Ready(None)) => return Ok(Async::Ready(())),
Ok(Async::NotReady) => (),
Ok(Async::NotReady) => return Ok(Async::NotReady),
Err(e) => debug!(target: "p_net", "Error getting consensus message: {:?}", e),
}
}
Binary file not shown.
-1
View File
@@ -19,7 +19,6 @@ polkadot-executor = { path = "../executor" }
polkadot-api = { path = "../api" }
polkadot-transaction-pool = { path = "../transaction-pool" }
polkadot-network = { path = "../network" }
substrate-keystore = { path = "../../substrate/keystore" }
substrate-runtime-io = { path = "../../substrate/runtime-io" }
substrate-primitives = { path = "../../substrate/primitives" }
substrate-network = { path = "../../substrate/network" }
+2 -6
View File
@@ -26,7 +26,6 @@ extern crate polkadot_api;
extern crate polkadot_consensus as consensus;
extern crate polkadot_transaction_pool as transaction_pool;
extern crate polkadot_network;
extern crate substrate_keystore as keystore;
extern crate substrate_primitives as primitives;
extern crate substrate_network as network;
extern crate substrate_codec as codec;
@@ -46,7 +45,6 @@ use std::collections::HashMap;
use codec::Slicable;
use transaction_pool::TransactionPool;
use keystore::Store as Keystore;
use polkadot_api::{PolkadotApi, light::RemotePolkadotApiWrapper};
use polkadot_primitives::{Block, BlockId, Hash};
use polkadot_runtime::GenesisConfig;
@@ -168,14 +166,12 @@ pub fn new_light(config: Configuration<GenesisConfig>, executor: TaskExecutor)
pub fn new_full(config: Configuration<GenesisConfig>, executor: TaskExecutor)
-> Result<Service<FullComponents<Factory>>, Error>
{
let keystore_path = config.keystore_path.clone();
let is_validator = (config.roles & Role::AUTHORITY) == Role::AUTHORITY;
let service = service::Service::<FullComponents<Factory>>::new(config, executor.clone())?;
// Spin consensus service if configured
let consensus = if is_validator {
// Spin consensus service if configured
let keystore = Keystore::open(keystore_path.into())?;
// Load the first available key
let key = keystore.load(&keystore.contents()?[0], "")?;
let key = service.keystore().load(&service.keystore().contents()?[0], "")?;
info!("Using authority key {}", key.public());
let client = service.client();
@@ -74,7 +74,7 @@ impl<B: BlockT> ConsensusGossip<B> where B::Header: HeaderT<Number=u64> {
/// Handle new connected peer.
pub fn new_peer(&mut self, protocol: &mut Context<B>, peer_id: PeerId, roles: &[message::Role]) {
if roles.iter().any(|r| *r == message::Role::Authority) {
if roles.iter().any(|r| *r == message::Role::Validator) {
trace!(target:"gossip", "Registering authority {}", peer_id);
// Send out all known messages.
// TODO: limit by size
@@ -20,6 +20,7 @@ use client::BlockOrigin;
use test_client::{self, TestClient};
use test_client::runtime::Header;
#[ignore]
#[test]
fn should_return_header() {
let core = ::tokio::runtime::Runtime::new().unwrap();
@@ -46,6 +47,7 @@ fn should_return_header() {
);
}
#[ignore]
#[test]
fn should_notify_about_latest_block() {
let mut core = ::tokio::runtime::Runtime::new().unwrap();
+7
View File
@@ -75,6 +75,7 @@ pub struct Service<Components: components::Components> {
client: Arc<ComponentClient<Components>>,
network: Arc<components::NetworkService<Components::Factory>>,
extrinsic_pool: Arc<Components::ExtrinsicPool>,
keystore: Keystore,
signal: Option<Signal>,
}
@@ -179,6 +180,7 @@ impl<Components> Service<Components>
network: network,
extrinsic_pool: extrinsic_pool,
signal: Some(signal),
keystore: keystore,
})
}
@@ -196,6 +198,11 @@ impl<Components> Service<Components>
pub fn extrinsic_pool(&self) -> Arc<PoolApi<Components>> {
self.extrinsic_pool.api()
}
/// Get shared keystore.
pub fn keystore(&self) -> &Keystore {
&self.keystore
}
}
impl<Components> Drop for Service<Components> where Components: components::Components {
Binary file not shown.