Split polkadot-service (#310)

* Substrate service

* Splitting polkadot service

* Specialised components

* Specialised components

* Docs and style

* Docs and style

* Final touches

* Added db key assertion
This commit is contained in:
Arkadiy Paronyan
2018-07-14 18:07:11 +02:00
committed by Gav Wood
parent c2f78371f1
commit 16ff3579ef
16 changed files with 442 additions and 884 deletions
+8 -8
View File
@@ -22,9 +22,9 @@ use service::{Service, Components};
use tokio::runtime::TaskExecutor;
use tokio::timer::Interval;
use network::{SyncState, SyncProvider};
use polkadot_primitives::Block;
use state_machine;
use client::{self, BlockchainEvents};
use client::BlockchainEvents;
use runtime_primitives::traits::{Header, As};
use substrate_extrinsic_pool::api::ExtrinsicPool;
const TIMER_INTERVAL_MS: u64 = 5000;
@@ -32,13 +32,12 @@ const TIMER_INTERVAL_MS: u64 = 5000;
pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExecutor)
where
C: Components,
client::error::Error: From<<<<C as Components>::Backend as client::backend::Backend<Block>>::State as state_machine::Backend>::Error>,
{
let interval = Interval::new(Instant::now(), Duration::from_millis(TIMER_INTERVAL_MS));
let network = service.network();
let client = service.client();
let txpool = service.transaction_pool();
let txpool = service.extrinsic_pool();
let display_notifications = interval.map_err(|e| debug!("Timer error: {:?}", e)).for_each(move |_| {
let sync_status = network.status();
@@ -52,8 +51,9 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
(SyncState::Downloading, Some(n)) => format!("Syncing, target=#{}", n),
};
let txpool_status = txpool.light_status();
info!(target: "polkadot", "{} ({} peers), best: #{} ({})", status, sync_status.num_peers, best_block.number, hash);
telemetry!("system.interval"; "status" => status, "peers" => num_peers, "height" => best_block.number, "best" => ?hash, "txcount" => txpool_status.transaction_count);
let best_number: u64 = best_block.number().as_();
info!(target: "polkadot", "{} ({} peers), best: #{} ({})", status, sync_status.num_peers, best_number, hash);
telemetry!("system.interval"; "status" => status, "peers" => num_peers, "height" => best_number, "best" => ?hash, "txcount" => txpool_status.transaction_count);
} else {
warn!("Error getting best block information");
}
@@ -66,7 +66,7 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
Ok(())
});
let txpool = service.transaction_pool();
let txpool = service.extrinsic_pool();
let display_txpool_import = txpool.import_notification_stream().for_each(move |_| {
let status = txpool.light_status();
telemetry!("txpool.import"; "mem_usage" => status.mem_usage, "count" => status.transaction_count, "sender" => status.senders);