Skip to content

Commit

Permalink
uniform hash in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
zeegomo committed Sep 24, 2021
1 parent 830c868 commit 7419ff1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions jormungandr/src/blockchain/process.rs
Expand Up @@ -31,9 +31,6 @@ type GetNextBlockScheduler = FireForgetScheduler<HeaderHash, Address, ()>;

const TIP_UPDATE_QUEUE_SIZE: usize = 5;

// it's a bit unnecessary to display the whole hash in logs
const HASH_LOG_LENGTH: usize = 7;

const DEFAULT_TIMEOUT_PROCESS_LEADERSHIP: u64 = 5;
const DEFAULT_TIMEOUT_PROCESS_ANNOUNCEMENT: u64 = 5;
const DEFAULT_TIMEOUT_PROCESS_BLOCKS: u64 = 60;
Expand Down Expand Up @@ -211,9 +208,9 @@ impl Process {
parent: self.service_info.span(),
Level::DEBUG,
"process_leadership_block",
hash = %leadership_block.block.header.description(),
parent = %leadership_block.block.header.parent_id().to_string()[..HASH_LOG_LENGTH],
date = %leadership_block.block.header.block_date().to_string()
hash = %leadership_block.block.header.hash(),
parent = %leadership_block.block.header.parent_id(),
date = %leadership_block.block.header.block_date()
);
let _enter = span.enter();
tracing::info!("receiving block from leadership service");
Expand All @@ -236,10 +233,10 @@ impl Process {
parent: self.service_info.span(),
Level::DEBUG,
"process_announced_block",
hash = %header.description(),
parent = %header.parent_id().to_string()[..HASH_LOG_LENGTH],
date = %header.block_date().to_string(),
peer = %node_id.to_string()
hash = %header.hash(),
parent = %header.parent_id(),
date = %header.block_date(),
peer = %node_id
);
let _enter = span.enter();
tracing::info!("received block announcement from network");
Expand Down Expand Up @@ -325,7 +322,7 @@ async fn process_and_propagate_new_ref(
mut network_msg_box: MessageBox<NetworkMsg>,
) -> chain::Result<()> {
let header = new_block_ref.header().clone();
let span = span!(Level::DEBUG, "process_and_propagate_new_ref", block = %header.description());
let span = span!(Level::DEBUG, "process_and_propagate_new_ref", block = %header.hash());

async {
tracing::debug!("processing the new block and propagating");
Expand Down Expand Up @@ -506,8 +503,8 @@ async fn process_network_block(
let span = tracing::span!(
Level::DEBUG,
"network_block",
block = %header.description(),
parent = %header.parent_id().to_string()[..HASH_LOG_LENGTH],
block = %header.hash(),
parent = %header.parent_id(),
date = %header.block_date(),
);

Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/network/mod.rs
Expand Up @@ -398,7 +398,7 @@ async fn handle_propagation_msg(
.await?
}
PropagateMsg::Fragment(fragment) => {
Span::current().record("hash", &format_args!("{:.8}", fragment.hash()));
Span::current().record("hash", &format_args!("{}", fragment.hash()));
tracing::debug!(hash = %fragment.hash(), "fragment to propagate");
let fragment = fragment.encode();
propagate_message(
Expand Down

0 comments on commit 7419ff1

Please sign in to comment.