Skip to content

Commit

Permalink
Merge pull request #6 from poanetwork/afck-0.1.0
Browse files Browse the repository at this point in the history
Update Rust, Clippy, Rustfmt.
  • Loading branch information
afck authored May 21, 2018
2 parents 48ae99c + 2a70cd3 commit 952a3e8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dist: trusty
language: rust
services: docker
sudo: required
rust: nightly-2018-04-19
rust: nightly-2018-05-19
cache: cargo

env:
Expand All @@ -24,7 +24,7 @@ before_install:
- set -e
- rustup self update
- rustup component add rustfmt-preview
# - cargo install clippy -f --vers=0.0.195
- cargo install clippy -f --vers=0.0.202

install:
- sh ci/install.sh
Expand All @@ -44,7 +44,7 @@ deploy:
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
on:
condition: $TRAVIS_RUST_VERSION = nightly-2018-04-19
condition: $TRAVIS_RUST_VERSION = nightly-2018-05-19
tags: true
provider: releases
skip_cleanup: true
Expand Down
4 changes: 3 additions & 1 deletion ci/script.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set -ex

main() {
cargo fmt -- --write-mode=diff
cargo fmt -- --check

cross build --target $TARGET
cross build --target $TARGET --release
Expand All @@ -14,6 +14,8 @@ main() {
cross test --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
Expand Down
38 changes: 22 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,28 @@ use web3::futures::Future;
/// The maximum age in seconds of the latest block.
const MAX_BLOCK_AGE: u64 = 60 * 60;

use_contract!(
net_con,
"NetworkConsensus",
"abi/PoaNetworkConsensus.abi.json"
);
use_contract!(
voting,
"VotingToChangeKeys",
"abi/VotingToChangeKeys.abi.json"
);
use_contract!(
val_meta,
"ValidatorMetadata",
"abi/ValidatorMetadata.abi.json"
);
use_contract!(key_mgr, "KeysManager", "abi/KeysManager.abi.json");
// The `use_contract!` macro triggers several Clippy warnings.
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, redundant_closure, needless_update))]
mod contracts {
use_contract!(
net_con,
"NetworkConsensus",
"abi/PoaNetworkConsensus.abi.json"
);
use_contract!(
voting,
"VotingToChangeKeys",
"abi/VotingToChangeKeys.abi.json"
);
use_contract!(
val_meta,
"ValidatorMetadata",
"abi/ValidatorMetadata.abi.json"
);
use_contract!(key_mgr, "KeysManager", "abi/KeysManager.abi.json");
}

use contracts::*;

#[derive(Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
Expand Down
6 changes: 4 additions & 2 deletions src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ impl Stats {
/// `votes` are the ones that were actually cast.
pub fn add_ballot(&mut self, voters: &[Address], votes: &[voting::logs::Vote]) {
for voter in voters {
let mut vs = self.voter_stats
let mut vs = self
.voter_stats
.entry(voter.clone())
.or_insert_with(VoterStats::default);
vs.ballots += 1;
Expand Down Expand Up @@ -59,7 +60,8 @@ impl Stats {

impl Display for Stats {
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()
.map(|(addr, s)| DisplayLine {
votes_per_thousand: s.voted * 1000 / s.ballots,
Expand Down

0 comments on commit 952a3e8

Please sign in to comment.