nicer tracing

This commit is contained in:
keorn 2016-12-11 22:54:48 +01:00
parent a4bf914683
commit 3c5d5856d2
3 changed files with 17 additions and 16 deletions

View File

@ -169,7 +169,7 @@ impl Tendermint {
let message_rlp = message_full_rlp(&signature, &vote_info); let message_rlp = message_full_rlp(&signature, &vote_info);
let message = ConsensusMessage::new(signature, h, r, *s, block_hash); let message = ConsensusMessage::new(signature, h, r, *s, block_hash);
self.votes.vote(message.clone(), *authority); self.votes.vote(message.clone(), *authority);
debug!(target: "poa", "Generated a message: {:?}.", message); debug!(target: "poa", "Generated {:?} as {}.", message, *authority);
self.handle_valid_message(&message); self.handle_valid_message(&message);
Some(message_rlp) Some(message_rlp)
@ -362,7 +362,7 @@ impl Tendermint {
}; };
if let Some(step) = next_step { if let Some(step) = next_step {
trace!(target: "poa", "handle_valid_message: Transition triggered."); trace!(target: "poa", "handle_valid_message: Transition to {:?} triggered.", step);
self.to_step(step); self.to_step(step);
} }
} }
@ -457,13 +457,10 @@ impl Engine for Tendermint {
if !self.is_authority(&sender) { if !self.is_authority(&sender) {
try!(Err(EngineError::NotAuthorized(sender))); try!(Err(EngineError::NotAuthorized(sender)));
} }
self.votes.vote(message.clone(), sender);
self.broadcast_message(rlp.as_raw().to_vec()); self.broadcast_message(rlp.as_raw().to_vec());
trace!(target: "poa", "Handling a valid message: {:?}", message); trace!(target: "poa", "Handling a valid {:?} from {}.", message, sender);
self.votes.vote(message.clone(), sender);
self.handle_valid_message(&message); self.handle_valid_message(&message);
} else {
trace!(target: "poa", "handle_message: Old or known message ignored: {:?}.", message);
} }
Ok(()) Ok(())
} }

View File

@ -49,10 +49,10 @@ impl TendermintTimeouts {
impl Default for TendermintTimeouts { impl Default for TendermintTimeouts {
fn default() -> Self { fn default() -> Self {
TendermintTimeouts { TendermintTimeouts {
propose: Duration::milliseconds(2000), propose: Duration::milliseconds(10000),
prevote: Duration::milliseconds(2000), prevote: Duration::milliseconds(10000),
precommit: Duration::milliseconds(2000), precommit: Duration::milliseconds(10000),
commit: Duration::milliseconds(2000), commit: Duration::milliseconds(10000),
} }
} }
} }

View File

@ -62,10 +62,14 @@ impl VoteCollector {
} }
pub fn is_old_or_known(&self, message: &ConsensusMessage) -> bool { pub fn is_old_or_known(&self, message: &ConsensusMessage) -> bool {
self.votes.read().contains_key(message) self.votes.read().get(message).map_or(false, |a| {
|| { trace!(target: "poa", "Known message from {}: {:?}.", a, message);
true
}) || {
let guard = self.votes.read(); let guard = self.votes.read();
guard.keys().next().map_or(true, |oldest| message <= oldest) let is_old = guard.keys().next().map_or(true, |oldest| message <= oldest);
if is_old { trace!(target: "poa", "Old message {:?}.", message); }
is_old
} }
} }