Bring substrate-demo up to date (#658)

* Updating substrate-demo

* Consenus fixes

* Reverted toolchain change

* Adjusted timeout formula

* Simplfied proposal creation

* Fixed tests

* Fixed a few small issues

* 2017->2018

* Style

* More style

* Renamed demo executable to substrate

* Style

* Fixed compilation after merge

* Style
This commit is contained in:
Arkadiy Paronyan
2018-09-10 17:54:32 +02:00
committed by Gav Wood
parent bcc26dd30a
commit fea750511e
41 changed files with 2940 additions and 312 deletions
+41 -2
View File
@@ -1,4 +1,4 @@
// Copyright 2017 Parity Technologies (UK) Ltd.
// Copyright 2018 Parity Technologies (UK) Ltd.
// This file is part of Substrate Demo.
// Substrate Demo is free software: you can redistribute it and/or modify
@@ -19,12 +19,51 @@
#![warn(missing_docs)]
extern crate demo_cli as cli;
extern crate ctrlc;
extern crate futures;
#[macro_use]
extern crate error_chain;
use cli::VersionInfo;
use futures::sync::oneshot;
use futures::{future, Future};
use std::cell::RefCell;
mod vergen {
#![allow(unused)]
include!(concat!(env!("OUT_DIR"), "/version.rs"));
}
// handles ctrl-c
struct Exit;
impl cli::IntoExit for Exit {
type Exit = future::MapErr<oneshot::Receiver<()>, fn(oneshot::Canceled) -> ()>;
fn into_exit(self) -> Self::Exit {
// can't use signal directly here because CtrlC takes only `Fn`.
let (exit_send, exit) = oneshot::channel();
let exit_send_cell = RefCell::new(Some(exit_send));
ctrlc::set_handler(move || {
if let Some(exit_send) = exit_send_cell.try_borrow_mut().expect("signal handler not reentrant; qed").take() {
exit_send.send(()).expect("Error sending exit notification");
}
}).expect("Error setting Ctrl-C handler");
exit.map_err(drop)
}
}
quick_main!(run);
fn run() -> cli::error::Result<()> {
cli::run(::std::env::args())
let version = VersionInfo {
commit: vergen::short_sha(),
version: env!("CARGO_PKG_VERSION"),
executable_name: "substrate",
author: "Parity Team <admin@parity.io>",
description: "Generic substrate node",
};
cli::run(::std::env::args(), Exit, version)
}