fix compilation

This commit is contained in:
keorn 2016-11-16 13:13:21 +00:00
parent 2fa34fd6a8
commit 3b0d5503b1
4 changed files with 22 additions and 19 deletions

View File

@ -41,7 +41,7 @@ use evm::Schedule;
use io::{IoService, IoChannel}; use io::{IoService, IoChannel};
use service::ClientIoMessage; use service::ClientIoMessage;
use self::message::ConsensusMessage; use self::message::ConsensusMessage;
use self::timeout::{TimerHandler, NextStep}; use self::timeout::{TransitionHandler, NextStep};
use self::params::TendermintParams; use self::params::TendermintParams;
use self::vote_collector::VoteCollector; use self::vote_collector::VoteCollector;
@ -102,7 +102,7 @@ impl Tendermint {
proposed_block: Mutex::new(None), proposed_block: Mutex::new(None),
message_channel: 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))); try!(engine.step_service.register_handler(Arc::new(handler)));
Ok(engine) Ok(engine)
} }
@ -241,7 +241,7 @@ impl Engine for Tendermint {
if let Ok(signature) = ap.sign(*author, None, block_hash(header)) { if let Ok(signature) = ap.sign(*author, None, block_hash(header)) {
return Some(vec![ return Some(vec![
::rlp::encode(&self.round.load(AtomicOrdering::SeqCst)).to_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() Vec::new()
]) ])
} else { } else {
@ -271,10 +271,12 @@ impl Engine for Tendermint {
if votes.len() > self.threshold() { if votes.len() > self.threshold() {
} }
}, },
Step::Precommit => , Step::Precommit => {},
_ => {},
} }
} }
self.votes.vote(message, sender); self.votes.vote(message, sender);
Err(BlockError::InvalidSeal.into())
} }
fn verify_block_basic(&self, header: &Header, _block: Option<&[u8]>) -> Result<(), Error> { fn verify_block_basic(&self, header: &Header, _block: Option<&[u8]>) -> Result<(), Error> {

View File

@ -16,16 +16,14 @@
//! Tendermint timeout handling. //! Tendermint timeout handling.
use util::Mutex;
use std::sync::atomic::{Ordering as AtomicOrdering}; use std::sync::atomic::{Ordering as AtomicOrdering};
use std::sync::Weak; use std::sync::Weak;
use io::{IoContext, IoHandler, TimerToken, IoChannel}; use io::{IoContext, IoHandler, TimerToken};
use super::{Tendermint, Step}; use super::{Tendermint, Step};
use time::{get_time, Duration}; use time::Duration;
use service::ClientIoMessage;
pub struct TimerHandler { pub struct TransitionHandler {
engine: Weak<Tendermint>, pub engine: Weak<Tendermint>,
} }
/// Base timeout of each step in ms. /// Base timeout of each step in ms.
@ -70,7 +68,7 @@ fn set_timeout(io: &IoContext<NextStep>, timeout: Duration) {
.unwrap_or_else(|e| warn!(target: "poa", "Failed to set consensus step timeout: {}.", e)) .unwrap_or_else(|e| warn!(target: "poa", "Failed to set consensus step timeout: {}.", e))
} }
impl IoHandler<NextStep> for TimerHandler { impl IoHandler<NextStep> for TransitionHandler {
fn initialize(&self, io: &IoContext<NextStep>) { fn initialize(&self, io: &IoContext<NextStep>) {
if let Some(engine) = self.engine.upgrade() { if let Some(engine) = self.engine.upgrade() {
set_timeout(io, engine.our_params.timeouts.propose) set_timeout(io, engine.our_params.timeouts.propose)
@ -104,7 +102,7 @@ impl IoHandler<NextStep> for TimerHandler {
}; };
if let Some(step) = next_step { if let Some(step) = next_step {
*engine.step.write() = step; *engine.step.write() = step.clone();
if step == Step::Propose { if step == Step::Propose {
engine.update_sealing(); engine.update_sealing();
} }
@ -115,9 +113,12 @@ impl IoHandler<NextStep> for TimerHandler {
fn message(&self, io: &IoContext<NextStep>, message: &NextStep) { fn message(&self, io: &IoContext<NextStep>, message: &NextStep) {
if let Some(engine) = self.engine.upgrade() { if let Some(engine) = self.engine.upgrade() {
io.clear_timer(ENGINE_TIMEOUT_TOKEN); match io.clear_timer(ENGINE_TIMEOUT_TOKEN) {
let NextStep(next_step) = *message; Ok(_) => {},
*engine.step.write() = next_step; 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 { match next_step {
Step::Propose => { Step::Propose => {
engine.update_sealing(); engine.update_sealing();

View File

@ -280,7 +280,7 @@ impl ChainNotify for EthSync {
} }
fn stop(&self) { 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)); self.network.stop().unwrap_or_else(|e| warn!("Error stopping network: {:?}", e));
} }

View File

@ -37,7 +37,7 @@ const GENERIC_PACKET: u8 = 0x01;
pub struct NetworkStatus { pub struct NetworkStatus {
pub protocol_version: u8, pub protocol_version: u8,
/// The underlying p2p network version. /// The underlying p2p network version.
pub network_id: U256, pub network_id: usize,
/// Total number of connected peers /// Total number of connected peers
pub num_peers: usize, pub num_peers: usize,
/// Total number of active peers /// Total number of active peers
@ -52,7 +52,7 @@ struct PeerInfo {
/// Peer chain genesis hash /// Peer chain genesis hash
genesis: H256, genesis: H256,
/// Peer network id /// Peer network id
network_id: U256, network_id: usize,
} }
/// Infinity protocol handler. /// Infinity protocol handler.
@ -61,7 +61,7 @@ pub struct InfinitySync {
/// All connected peers /// All connected peers
peers: HashMap<PeerId, PeerInfo>, peers: HashMap<PeerId, PeerInfo>,
/// Network ID /// Network ID
network_id: U256, network_id: usize,
} }
impl InfinitySync { impl InfinitySync {