* Start to remove the `As` bound on `SimpleArtithmetic`

This just introduces standard numeric bounds, assuming a minimum of
`u32`. Also included is a saturating from/into trait allowing ergonomic
infallible conversion when you don't care if it saturates.

* Remove As from Balances trait

* Remove As from Aura module

* Remove As from Babe module

* Expunge `As` from contract

* Council module

* Democracy

* Finality tracker

* Grandpa

* First bit of indices

* indices

* Line lengths

* session

* system

* Staking

* Square up all other uses of As.

* RHD update

* Fix build/test

* Remove As trait

* line widths

* Remove final As ref

* Update srml/staking/src/lib.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update core/client/src/cht.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update core/client/db/src/light.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* whitespace

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
Co-Authored-By: André Silva <andre.beat@gmail.com>

* Bring back u32 check for number on CLI
This commit is contained in:
Gavin Wood
2019-05-22 23:11:38 +01:00
committed by GitHub
parent 36987c0205
commit 3860d7c810
60 changed files with 695 additions and 491 deletions
+3 -3
View File
@@ -29,7 +29,7 @@ use substrate_telemetry::{telemetry, SUBSTRATE_INFO};
use log::{info, warn};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{Header, As};
use runtime_primitives::traits::{Header, SaturatedConversion};
/// Spawn informant on the event loop
pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExecutor) where
@@ -47,7 +47,7 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
let display_notifications = network.status().for_each(move |sync_status| {
if let Ok(info) = client.info() {
let best_number: u64 = info.chain.best_number.as_();
let best_number = info.chain.best_number.saturated_into::<u64>();
let best_hash = info.chain.best_hash;
let num_peers = sync_status.num_peers;
let speed = move || speed(best_number, last_number, last_update);
@@ -59,7 +59,7 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
};
last_number = Some(best_number);
let txpool_status = txpool.status();
let finalized_number: u64 = info.chain.finalized_number.as_();
let finalized_number: u64 = info.chain.finalized_number.saturated_into::<u64>();
let bandwidth_download = network.average_download_per_sec();
let bandwidth_upload = network.average_upload_per_sec();
info!(
+2 -3
View File
@@ -26,7 +26,6 @@ pub mod error;
pub mod informant;
use client::ExecutionStrategies;
use runtime_primitives::traits::As;
use service::{
ServiceFactory, FactoryFullConfiguration, RuntimeGenesis,
FactoryGenesis, PruningMode, ChainSpec,
@@ -627,7 +626,7 @@ where
};
service::chain_ops::export_blocks::<F, _, _>(
config, exit.into_exit(), file, As::sa(from), to.map(As::sa), json
config, exit.into_exit(), file, from.into(), to.map(Into::into), json
).map_err(Into::into)
}
@@ -663,7 +662,7 @@ where
{
let config = create_config_with_db_path::<F, _>(spec_factory, &cli.shared_params, version)?;
let blocks = cli.num;
Ok(service::chain_ops::revert_chain::<F>(config, As::sa(blocks))?)
Ok(service::chain_ops::revert_chain::<F>(config, blocks.into())?)
}
fn purge_chain<F, S>(
+3 -3
View File
@@ -533,11 +533,11 @@ pub struct ExportBlocksCmd {
/// Specify starting block number. 1 by default.
#[structopt(long = "from", value_name = "BLOCK")]
pub from: Option<u64>,
pub from: Option<u32>,
/// Specify last block number. Best block by default.
#[structopt(long = "to", value_name = "BLOCK")]
pub to: Option<u64>,
pub to: Option<u32>,
/// Use JSON output rather than binary.
#[structopt(long = "json")]
@@ -573,7 +573,7 @@ impl_get_log_filter!(ImportBlocksCmd);
pub struct RevertCmd {
/// Number of blocks to revert.
#[structopt(default_value = "256")]
pub num: u64,
pub num: u32,
#[allow(missing_docs)]
#[structopt(flatten)]