Update Rust, Clippy, Rustfmt.
Clippy 0.0.202 fixes a bug that prevented using it here. https://github.com/rust-lang-nursery/rust-clippy/issues/2594
This commit is contained in:
parent
ac7e6e80d2
commit
2a70cd3998
|
@ -5,7 +5,7 @@ dist: trusty
|
||||||
language: rust
|
language: rust
|
||||||
services: docker
|
services: docker
|
||||||
sudo: required
|
sudo: required
|
||||||
rust: nightly-2018-04-19
|
rust: nightly-2018-05-19
|
||||||
cache: cargo
|
cache: cargo
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
@ -24,7 +24,7 @@ before_install:
|
||||||
- set -e
|
- set -e
|
||||||
- rustup self update
|
- rustup self update
|
||||||
- rustup component add rustfmt-preview
|
- rustup component add rustfmt-preview
|
||||||
# - cargo install clippy -f --vers=0.0.195
|
- cargo install clippy -f --vers=0.0.202
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- sh ci/install.sh
|
- sh ci/install.sh
|
||||||
|
@ -44,7 +44,7 @@ deploy:
|
||||||
file_glob: true
|
file_glob: true
|
||||||
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
|
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
|
||||||
on:
|
on:
|
||||||
condition: $TRAVIS_RUST_VERSION = nightly-2018-04-19
|
condition: $TRAVIS_RUST_VERSION = nightly-2018-05-19
|
||||||
tags: true
|
tags: true
|
||||||
provider: releases
|
provider: releases
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
cargo fmt -- --write-mode=diff
|
cargo fmt -- --check
|
||||||
|
|
||||||
cross build --target $TARGET
|
cross build --target $TARGET
|
||||||
cross build --target $TARGET --release
|
cross build --target $TARGET --release
|
||||||
|
@ -14,6 +14,8 @@ main() {
|
||||||
cross test --target $TARGET --release
|
cross test --target $TARGET --release
|
||||||
|
|
||||||
cross build --target $TARGET --release
|
cross build --target $TARGET --release
|
||||||
|
|
||||||
|
cross clippy --tests --all-features -- -D clippy
|
||||||
}
|
}
|
||||||
|
|
||||||
# we don't run the "test phase" when doing deploys
|
# we don't run the "test phase" when doing deploys
|
||||||
|
|
38
src/main.rs
38
src/main.rs
|
@ -31,22 +31,28 @@ use web3::futures::Future;
|
||||||
/// The maximum age in seconds of the latest block.
|
/// The maximum age in seconds of the latest block.
|
||||||
const MAX_BLOCK_AGE: u64 = 60 * 60;
|
const MAX_BLOCK_AGE: u64 = 60 * 60;
|
||||||
|
|
||||||
use_contract!(
|
// The `use_contract!` macro triggers several Clippy warnings.
|
||||||
net_con,
|
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, redundant_closure, needless_update))]
|
||||||
"NetworkConsensus",
|
mod contracts {
|
||||||
"abi/PoaNetworkConsensus.abi.json"
|
use_contract!(
|
||||||
);
|
net_con,
|
||||||
use_contract!(
|
"NetworkConsensus",
|
||||||
voting,
|
"abi/PoaNetworkConsensus.abi.json"
|
||||||
"VotingToChangeKeys",
|
);
|
||||||
"abi/VotingToChangeKeys.abi.json"
|
use_contract!(
|
||||||
);
|
voting,
|
||||||
use_contract!(
|
"VotingToChangeKeys",
|
||||||
val_meta,
|
"abi/VotingToChangeKeys.abi.json"
|
||||||
"ValidatorMetadata",
|
);
|
||||||
"abi/ValidatorMetadata.abi.json"
|
use_contract!(
|
||||||
);
|
val_meta,
|
||||||
use_contract!(key_mgr, "KeysManager", "abi/KeysManager.abi.json");
|
"ValidatorMetadata",
|
||||||
|
"abi/ValidatorMetadata.abi.json"
|
||||||
|
);
|
||||||
|
use_contract!(key_mgr, "KeysManager", "abi/KeysManager.abi.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
use contracts::*;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||||
|
|
|
@ -29,7 +29,8 @@ impl Stats {
|
||||||
/// `votes` are the ones that were actually cast.
|
/// `votes` are the ones that were actually cast.
|
||||||
pub fn add_ballot(&mut self, voters: &[Address], votes: &[voting::logs::Vote]) {
|
pub fn add_ballot(&mut self, voters: &[Address], votes: &[voting::logs::Vote]) {
|
||||||
for voter in voters {
|
for voter in voters {
|
||||||
let mut vs = self.voter_stats
|
let mut vs = self
|
||||||
|
.voter_stats
|
||||||
.entry(voter.clone())
|
.entry(voter.clone())
|
||||||
.or_insert_with(VoterStats::default);
|
.or_insert_with(VoterStats::default);
|
||||||
vs.ballots += 1;
|
vs.ballots += 1;
|
||||||
|
@ -59,7 +60,8 @@ impl Stats {
|
||||||
|
|
||||||
impl Display for Stats {
|
impl Display for Stats {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
let mut lines: Vec<DisplayLine> = self.voter_stats
|
let mut lines: Vec<DisplayLine> = self
|
||||||
|
.voter_stats
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(addr, s)| DisplayLine {
|
.map(|(addr, s)| DisplayLine {
|
||||||
votes_per_thousand: s.voted * 1000 / s.ballots,
|
votes_per_thousand: s.voted * 1000 / s.ballots,
|
||||||
|
|
Loading…
Reference in New Issue