Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joske committed May 6, 2024
1 parent abf19f6 commit 1534c87
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
8 changes: 7 additions & 1 deletion cli/src/helpers/dynamic_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AtomicBool>,
}

Expand Down Expand Up @@ -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 =
Expand All @@ -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")?;
}
Expand Down
2 changes: 1 addition & 1 deletion node/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait NodeInterface<N: Network>: Routing<N> {
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,
Expand Down
2 changes: 1 addition & 1 deletion node/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ mod tests {
storage_mode,
false,
dev_txs,
Arc::new(AtomicBool::new(false)),
Default::default(),
)
.await
.unwrap();
Expand Down
11 changes: 4 additions & 7 deletions node/tests/common/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
Client::new(
Expand All @@ -33,7 +30,7 @@ pub async fn client() -> Client<CurrentNetwork, ConsensusMemory<CurrentNetwork>>
sample_genesis_block(),
None, // No CDN.
StorageMode::Production,
Arc::new(AtomicBool::new(false)),
Default::default(),
)
.await
.expect("couldn't create client instance")
Expand All @@ -46,7 +43,7 @@ pub async fn prover() -> Prover<CurrentNetwork, ConsensusMemory<CurrentNetwork>>
&[],
sample_genesis_block(),
StorageMode::Production,
Arc::new(AtomicBool::new(false)),
Default::default(),
)
.await
.expect("couldn't create prover instance")
Expand All @@ -66,7 +63,7 @@ pub async fn validator() -> Validator<CurrentNetwork, ConsensusMemory<CurrentNet
StorageMode::Production,
true, // This test requires validators to connect to peers.
false, // No dev traffic in production mode.
Arc::new(AtomicBool::new(false)),
Default::default(),
)
.await
.expect("couldn't create validator instance")
Expand Down

0 comments on commit 1534c87

Please sign in to comment.