Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Display tendermint::consensus::State height/round/step #316

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ where
let height = request.height().unwrap();

warn!(
"[{}:{}] attempt to double sign at height: {}",
&self.chain_id, &self.peer_addr, height
"[{}:{}] attempt to double sign at height/round/step: {}",
&self.chain_id, &self.peer_addr, request_state
);

let remote_err = RemoteError::double_sign(height);
Expand Down Expand Up @@ -242,8 +242,8 @@ where

/// Write an INFO logline about a signing request
fn log_signing_request<T: TendermintRequest + Debug>(&self, request: &T, started_at: Instant) {
let height = request
.height()
let consensus_state = request
.consensus_state()
.map(|h| h.to_string())
.unwrap_or_else(|| "none".to_owned());

Expand All @@ -253,11 +253,11 @@ where
.unwrap_or_else(|| "Unknown".to_owned());

info!(
"[{}@{}] signed {:?} at height: {} ({} ms)",
"[{}@{}] signed {:?} at height/round/step: {} ({} ms)",
&self.chain_id,
&self.peer_addr,
msg_type,
height,
consensus_state,
started_at.elapsed().as_millis()
);
}
Expand Down
8 changes: 7 additions & 1 deletion tendermint-rs/src/consensus/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Tendermint consensus state

pub use crate::block;
pub use std::cmp::Ordering;
pub use std::{cmp::Ordering, fmt};
#[cfg(feature = "serde")]
use {
crate::serializers,
Expand Down Expand Up @@ -32,6 +32,12 @@ pub struct State {
pub block_id: Option<block::Id>,
}

impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}/{}/{}", self.height, self.round, self.step)
}
}

impl Ord for State {
fn cmp(&self, other: &State) -> Ordering {
if self.height < other.height {
Expand Down