Skip to content

Commit

Permalink
Less noisy logging
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Feb 27, 2024
1 parent 6c47d84 commit b442080
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions code/gossip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use futures::StreamExt;
use libp2p::swarm::{self, NetworkBehaviour, SwarmEvent};
use libp2p::{gossipsub, identify, mdns, noise, tcp, yamux, SwarmBuilder};
use tokio::sync::mpsc;
use tracing::{debug, error, error_span, info, Instrument};
use tracing::{debug, error, error_span, Instrument};

pub use libp2p::identity::Keypair;
pub use libp2p::{Multiaddr, PeerId};
Expand Down Expand Up @@ -215,7 +215,7 @@ async fn handle_swarm_event(
) -> ControlFlow<()> {
match event {
SwarmEvent::NewListenAddr { address, .. } => {
info!("Node is listening on {address}");
debug!("Node is listening on {address}");

if let Err(e) = tx_event.send(HandleEvent::Listening(address)).await {
error!("Error sending listening event to handle: {e}");
Expand Down
10 changes: 7 additions & 3 deletions code/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,13 @@ where
msg: NetworkMsg,
tx_input: &TxInput<Ctx>,
) {
info!("Received message from peer {peer_id}: {msg:?}");

match msg {
NetworkMsg::Vote(signed_vote) => {
let signed_vote = SignedVote::<Ctx>::from_proto(signed_vote).unwrap();
let signed_vote = SignedVote::<Ctx>::from_proto(signed_vote).unwrap(); // FIXME
let validator_address = signed_vote.validator_address();

info!(%peer_id, %validator_address, "Received vote: {:?}", signed_vote.vote);

let Some(validator) = self.params.validator_set.get_by_address(validator_address)
else {
warn!(%peer_id, %validator_address, "Received vote from unknown validator");
Expand All @@ -305,6 +306,9 @@ where
NetworkMsg::Proposal(proposal) => {
let signed_proposal = SignedProposal::<Ctx>::from_proto(proposal).unwrap();
let validator_address = signed_proposal.proposal.validator_address();

info!(%peer_id, %validator_address, "Received proposal: {:?}", signed_proposal.proposal);

let Some(validator) = self.params.validator_set.get_by_address(validator_address)
else {
warn!(%peer_id, %validator_address, "Received proposal from unknown validator");
Expand Down
9 changes: 8 additions & 1 deletion code/test/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use malachite_proto as proto;

use crate::signing::PublicKey;

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Address([u8; Self::LENGTH]);

impl Address {
Expand Down Expand Up @@ -34,6 +34,13 @@ impl fmt::Display for Address {
}
}

impl fmt::Debug for Address {
#[cfg_attr(coverage_nightly, coverage(off))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Address({})", self)
}
}

impl malachite_common::Address for Address {}

impl malachite_proto::Protobuf for Address {
Expand Down
8 changes: 7 additions & 1 deletion code/test/src/height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::fmt;
use malachite_proto as proto;

/// A blockchain height
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord)]
pub struct Height(u64);

impl Height {
Expand All @@ -22,6 +22,12 @@ impl fmt::Display for Height {
}
}

impl fmt::Debug for Height {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Height({})", self.0)
}
}

impl malachite_common::Height for Height {
fn increment(&self) -> Self {
Self(self.0 + 1)
Expand Down

0 comments on commit b442080

Please sign in to comment.