From 3b0d5503b14258c95e39995158f8ee3cec12e043 Mon Sep 17 00:00:00 2001 From: keorn Date: Wed, 16 Nov 2016 13:13:21 +0000 Subject: [PATCH] fix compilation --- ethcore/src/engines/tendermint/mod.rs | 10 ++++++---- ethcore/src/engines/tendermint/timeout.rs | 23 ++++++++++++----------- sync/src/api.rs | 2 +- sync/src/infinity.rs | 6 +++--- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ethcore/src/engines/tendermint/mod.rs b/ethcore/src/engines/tendermint/mod.rs index cc3283b5f..47ed8f828 100644 --- a/ethcore/src/engines/tendermint/mod.rs +++ b/ethcore/src/engines/tendermint/mod.rs @@ -41,7 +41,7 @@ use evm::Schedule; use io::{IoService, IoChannel}; use service::ClientIoMessage; use self::message::ConsensusMessage; -use self::timeout::{TimerHandler, NextStep}; +use self::timeout::{TransitionHandler, NextStep}; use self::params::TendermintParams; use self::vote_collector::VoteCollector; @@ -102,7 +102,7 @@ impl Tendermint { proposed_block: Mutex::new(None), message_channel: Mutex::new(None) }); - let handler = TimerHandler { engine: Arc::downgrade(&engine) }; + let handler = TransitionHandler { engine: Arc::downgrade(&engine) }; try!(engine.step_service.register_handler(Arc::new(handler))); Ok(engine) } @@ -241,7 +241,7 @@ impl Engine for Tendermint { if let Ok(signature) = ap.sign(*author, None, block_hash(header)) { return Some(vec![ ::rlp::encode(&self.round.load(AtomicOrdering::SeqCst)).to_vec(), - ::rlp::encode(&signature.into()).to_vec(), + ::rlp::encode(&H520::from(signature)).to_vec(), Vec::new() ]) } else { @@ -271,10 +271,12 @@ impl Engine for Tendermint { if votes.len() > self.threshold() { } }, - Step::Precommit => , + Step::Precommit => {}, + _ => {}, } } self.votes.vote(message, sender); + Err(BlockError::InvalidSeal.into()) } fn verify_block_basic(&self, header: &Header, _block: Option<&[u8]>) -> Result<(), Error> { diff --git a/ethcore/src/engines/tendermint/timeout.rs b/ethcore/src/engines/tendermint/timeout.rs index 64a21a299..789755077 100644 --- a/ethcore/src/engines/tendermint/timeout.rs +++ b/ethcore/src/engines/tendermint/timeout.rs @@ -16,16 +16,14 @@ //! Tendermint timeout handling. -use util::Mutex; use std::sync::atomic::{Ordering as AtomicOrdering}; use std::sync::Weak; -use io::{IoContext, IoHandler, TimerToken, IoChannel}; +use io::{IoContext, IoHandler, TimerToken}; use super::{Tendermint, Step}; -use time::{get_time, Duration}; -use service::ClientIoMessage; +use time::Duration; -pub struct TimerHandler { - engine: Weak, +pub struct TransitionHandler { + pub engine: Weak, } /// Base timeout of each step in ms. @@ -70,7 +68,7 @@ fn set_timeout(io: &IoContext, timeout: Duration) { .unwrap_or_else(|e| warn!(target: "poa", "Failed to set consensus step timeout: {}.", e)) } -impl IoHandler for TimerHandler { +impl IoHandler for TransitionHandler { fn initialize(&self, io: &IoContext) { if let Some(engine) = self.engine.upgrade() { set_timeout(io, engine.our_params.timeouts.propose) @@ -104,7 +102,7 @@ impl IoHandler for TimerHandler { }; if let Some(step) = next_step { - *engine.step.write() = step; + *engine.step.write() = step.clone(); if step == Step::Propose { engine.update_sealing(); } @@ -115,9 +113,12 @@ impl IoHandler for TimerHandler { fn message(&self, io: &IoContext, message: &NextStep) { if let Some(engine) = self.engine.upgrade() { - io.clear_timer(ENGINE_TIMEOUT_TOKEN); - let NextStep(next_step) = *message; - *engine.step.write() = next_step; + match io.clear_timer(ENGINE_TIMEOUT_TOKEN) { + Ok(_) => {}, + Err(io_err) => warn!(target: "poa", "Could not remove consensus timer {}.", io_err), + }; + let NextStep(next_step) = message.clone(); + *engine.step.write() = next_step.clone(); match next_step { Step::Propose => { engine.update_sealing(); diff --git a/sync/src/api.rs b/sync/src/api.rs index bba26e8cc..078cac74c 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -280,7 +280,7 @@ impl ChainNotify for EthSync { } fn stop(&self) { - self.handler.snapshot_service.abort_restore(); + self.eth_handler.snapshot_service.abort_restore(); self.network.stop().unwrap_or_else(|e| warn!("Error stopping network: {:?}", e)); } diff --git a/sync/src/infinity.rs b/sync/src/infinity.rs index 810db32ed..936060a1d 100644 --- a/sync/src/infinity.rs +++ b/sync/src/infinity.rs @@ -37,7 +37,7 @@ const GENERIC_PACKET: u8 = 0x01; pub struct NetworkStatus { pub protocol_version: u8, /// The underlying p2p network version. - pub network_id: U256, + pub network_id: usize, /// Total number of connected peers pub num_peers: usize, /// Total number of active peers @@ -52,7 +52,7 @@ struct PeerInfo { /// Peer chain genesis hash genesis: H256, /// Peer network id - network_id: U256, + network_id: usize, } /// Infinity protocol handler. @@ -61,7 +61,7 @@ pub struct InfinitySync { /// All connected peers peers: HashMap, /// Network ID - network_id: U256, + network_id: usize, } impl InfinitySync {