From 1534c8730b2f2b1581072462fc5b40cae3abe720 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 30 Apr 2024 13:31:40 +0200 Subject: [PATCH] fix: review comments --- cli/src/commands/start.rs | 2 +- cli/src/helpers/dynamic_format.rs | 8 +++++++- node/src/traits.rs | 2 +- node/src/validator/mod.rs | 2 +- node/tests/common/node.rs | 11 ++++------- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 09627331dd..2cfd66d310 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -579,7 +579,7 @@ impl Start { match node_type { NodeType::Validator => Node::new_validator(node_ip, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers, dev_txs, shutdown.clone()).await, NodeType::Prover => Node::new_prover(node_ip, account, &trusted_peers, genesis, storage_mode, shutdown.clone()).await, - NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode, shutdown.clone()).await, + NodeType::Client => Node::new_client(node_ip, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode, shutdown).await, } } diff --git a/cli/src/helpers/dynamic_format.rs b/cli/src/helpers/dynamic_format.rs index 82662d4860..6e062857ad 100644 --- a/cli/src/helpers/dynamic_format.rs +++ b/cli/src/helpers/dynamic_format.rs @@ -27,9 +27,11 @@ use tracing_subscriber::{ registry::LookupSpan, }; +/// A formatter that can switch between the default formatter and the DIM style. pub struct DynamicFormatter { dim_format: DimFormat, default_format: tracing_subscriber::fmt::format::Format, + // This is the shutdown flag. When set to true, switch to the DIM format. dim: Arc, } @@ -59,6 +61,9 @@ struct DimFormat { fmt: OwnedFormatItem, } +/// A custom format for the DIM style. +/// This formatter is quite basic and does not support all the features of the default formatter. +/// It does support all the default fields of the default formatter. impl DimFormat { fn new() -> Self { let format = @@ -73,8 +78,9 @@ where S: Subscriber + for<'a> LookupSpan<'a>, N: for<'a> FormatFields<'a> + 'static, { + /// Format like the `Full` format, but using the DIM tty style. fn format_event(&self, ctx: &FmtContext<'_, S, N>, mut writer: Writer<'_>, event: &Event<'_>) -> std::fmt::Result { - // set the DIM style + // set the DIM style if we are in TTY mode if writer.has_ansi_escapes() { write!(writer, "\x1b[2m")?; } diff --git a/node/src/traits.rs b/node/src/traits.rs index 56a6a4b592..9efe64350b 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -90,7 +90,7 @@ pub trait NodeInterface: Routing { tokio::task::spawn(async move { match signal_listener().await { Ok(()) => { - warn!("Orderly shutdown started, please wait until shutdown is complete."); + warn!("Orderly shutdown started, please wait until it is complete."); match node_clone.get() { // If the node is already initialized, then shut it down. Some(node) => node.shut_down().await, diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 47bc33699c..3b618bcc67 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -488,7 +488,7 @@ mod tests { storage_mode, false, dev_txs, - Arc::new(AtomicBool::new(false)), + Default::default(), ) .await .unwrap(); diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index aedfd88dd7..c88e35d969 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -18,10 +18,7 @@ use snarkos_node::{Client, Prover, Validator}; use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; use aleo_std::StorageMode; -use std::{ - str::FromStr, - sync::{atomic::AtomicBool, Arc}, -}; +use std::str::FromStr; pub async fn client() -> Client> { Client::new( @@ -33,7 +30,7 @@ pub async fn client() -> Client> sample_genesis_block(), None, // No CDN. StorageMode::Production, - Arc::new(AtomicBool::new(false)), + Default::default(), ) .await .expect("couldn't create client instance") @@ -46,7 +43,7 @@ pub async fn prover() -> Prover> &[], sample_genesis_block(), StorageMode::Production, - Arc::new(AtomicBool::new(false)), + Default::default(), ) .await .expect("couldn't create prover instance") @@ -66,7 +63,7 @@ pub async fn validator() -> Validator