Consensus message buffering and more (#114)

* CLI options and keystore integration

* Replace multiqueue with future::mpsc

* BFT gossip

* Revert to app_dirs

* generate_from_seed commented

* Refactor event loop

* Start consensus by timer

* Message buffering

* Minor fixes

* Work around duty-roster issue.

* some more minor fixes

* fix compilation

* more consistent formatting

* make bft input stream never conclude

* Minor fixes

* add timestamp module to executive

* more cleanups and logging

* Fixed message propagation
This commit is contained in:
Arkadiy Paronyan
2018-04-06 19:18:26 +02:00
committed by Gav Wood
parent 6a99c9a43d
commit f532982623
16 changed files with 245 additions and 81 deletions
+12 -9
View File
@@ -37,8 +37,6 @@ extern crate substrate_executor;
extern crate tokio_core;
extern crate substrate_client as client;
#[macro_use]
extern crate hex_literal;
#[macro_use]
extern crate error_chain;
#[macro_use]
@@ -141,8 +139,12 @@ impl Service {
}
let god_keys = vec![
hex!["f09c0d1467d6952c92c343672bfb06a24560f400af8cf98b93df7d40b4efe1b6"],
hex!["84718cd2894bcda83beeca3a7842caf269fe93cacde0bdee0e3cbce6de253f0e"]
ed25519::Pair::from_seed(b"Alice ").public().into(),
ed25519::Pair::from_seed(b"Bob ").public().into(),
// ed25519::Pair::from_seed(b"Charlie ").public().into(),
// ed25519::Pair::from_seed(b"Dave ").public().into(),
// ed25519::Pair::from_seed(b"Eve ").public().into(),
// ed25519::Pair::from_seed(b"Ferdie ").public().into(),
];
let genesis_config = GenesisConfig {
@@ -190,15 +192,16 @@ impl Service {
let prepare_genesis = || {
storage = genesis_config.build_externalities();
let block = genesis::construct_genesis_block(&storage);
with_externalities(&mut storage, ||
with_externalities(&mut storage, || {
// TODO: use api.rs to dispatch instead
polkadot_runtime::System::initialise_genesis_state(&block.header)
);
polkadot_runtime::System::initialise_genesis_state(&block.header);
info!("Genesis header hash: {}", polkadot_runtime::System::block_hash(0));
});
(primitives::block::Header::decode(&mut block.header.encode().as_ref()).expect("to_vec() always gives a valid serialisation; qed"), storage.into_iter().collect())
};
let client = Arc::new(client::new_in_mem(executor, prepare_genesis)?);
let best_header = client.header(&BlockId::Hash(client.info()?.chain.best_hash))?.expect("Best header always exists; qed");
let best_header = client.best_block_header()?;
info!("Starting Polkadot. Best block is #{}", best_header.number);
let transaction_pool = Arc::new(Mutex::new(TransactionPool::new(config.transaction_pool)));
let transaction_pool_adapter = Arc::new(TransactionPoolAdapter {
@@ -220,7 +223,7 @@ impl Service {
// Load the first available key. Code above makes sure it exisis.
let key = keystore.load(&keystore.contents()?[0], "")?;
info!("Using authority key {:?}", key.public());
Some(consensus::Service::new(client.clone(), network.clone(), transaction_pool.clone(), key, &best_header))
Some(consensus::Service::new(client.clone(), network.clone(), transaction_pool.clone(), key))
} else {
None
};