* 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
+7 -7
View File
@@ -21,7 +21,7 @@ use futures::Future;
use log::{info, warn};
use runtime_primitives::generic::{SignedBlock, BlockId};
use runtime_primitives::traits::{As, Block, Header, NumberFor};
use runtime_primitives::traits::{SaturatedConversion, Zero, One, Block, Header, NumberFor};
use consensus_common::import_queue::{ImportQueue, IncomingBlock, Link};
use network::message;
@@ -50,7 +50,7 @@ pub fn export_blocks<F, E, W>(
let mut block = from;
let last = match to {
Some(v) if v == As::sa(0) => As::sa(1),
Some(v) if v.is_zero() => One::one(),
Some(v) => v,
None => client.info()?.chain.best_number,
};
@@ -66,8 +66,8 @@ pub fn export_blocks<F, E, W>(
});
info!("Exporting blocks from #{} to #{}", block, last);
if !json {
let last_: u64 = last.as_();
let block_: u64 = block.as_();
let last_: u64 = last.saturated_into::<u64>();
let block_: u64 = block.saturated_into::<u64>();
let len: u64 = last_ - block_ + 1;
output.write(&len.encode())?;
}
@@ -87,13 +87,13 @@ pub fn export_blocks<F, E, W>(
},
None => break,
}
if block.as_() % 10000 == 0 {
if (block % 10000.into()).is_zero() {
info!("#{}", block);
}
if block == last {
break;
}
block += As::sa(1);
block += One::one();
}
Ok(())
}
@@ -202,7 +202,7 @@ pub fn revert_chain<F>(
let reverted = client.revert(blocks)?;
let info = client.info()?.chain;
if reverted.as_() == 0 {
if reverted.is_zero() {
info!("There aren't any non-finalized blocks to revert.");
} else {
info!("Reverted {} blocks. Best: #{} ({})", reverted, info.best_number, info.best_hash);
+5 -2
View File
@@ -40,7 +40,7 @@ use log::{info, warn, debug};
use parity_codec::{Encode, Decode};
use primitives::Pair;
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{Header, As};
use runtime_primitives::traits::{Header, SaturatedConversion};
use substrate_executor::NativeExecutor;
use tel::{telemetry, SUBSTRATE_INFO};
@@ -162,7 +162,10 @@ impl<Components: components::Components> Service<Components> {
let version = config.full_version();
info!("Highest known block at #{}", chain_info.best_number);
telemetry!(SUBSTRATE_INFO; "node.start"; "height" => chain_info.best_number.as_(), "best" => ?chain_info.best_hash);
telemetry!(SUBSTRATE_INFO; "node.start";
"height" => chain_info.best_number.saturated_into::<u64>(),
"best" => ?chain_info.best_hash
);
let network_protocol = <Components::Factory>::build_network_protocol(&config)?;
let transaction_pool = Arc::new(