Skip to content

Commit

Permalink
Moves ledger sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco authored and bengtlofgren committed May 10, 2023
1 parent 621c8d5 commit 4054816
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 19 additions & 1 deletion apps/src/bin/namada-node/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Namada node CLI.
use eyre::{Context, Result};
use namada::types::time::Utc;
use namada_apps::cli::{self, cmds};
use namada_apps::node::ledger;

Expand All @@ -13,7 +14,24 @@ pub fn main() -> Result<()> {
cmds::NamadaNode::Ledger(sub) => match sub {
cmds::Ledger::Run(cmds::LedgerRun(args)) => {
let wasm_dir = ctx.wasm_dir();
ledger::run(ctx.config.ledger, args, wasm_dir);

// Sleep until start time if needed
if let Some(time) = args.0 {
if let Ok(sleep_time) =
time.0.signed_duration_since(Utc::now()).to_std()
{
if !sleep_time.is_zero() {
tracing::info!(
"Waiting ledger start time: {:?}, time left: \
{:?}",
time,
sleep_time
);
std::thread::sleep(sleep_time)
}
}
}
ledger::run(ctx.config.ledger, wasm_dir);
}
cmds::Ledger::Reset(_) => {
ledger::reset(ctx.config.ledger)
Expand Down
20 changes: 1 addition & 19 deletions apps/src/lib/node/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ use byte_unit::Byte;
use futures::future::TryFutureExt;
use namada::ledger::governance::storage as gov_storage;
use namada::types::storage::Key;
use namada::types::time::Utc;
use once_cell::unsync::Lazy;
use sysinfo::{RefreshKind, System, SystemExt};
use tokio::task;
use tower::ServiceBuilder;

use self::abortable::AbortableSpawner;
use self::shims::abcipp_shim::AbciService;
use crate::cli::args;
use crate::config::utils::num_of_threads;
use crate::config::TendermintMode;
use crate::facade::tendermint_proto::abci::CheckTxType;
Expand Down Expand Up @@ -158,7 +156,7 @@ impl Shell {
}

/// Run the ledger with an async runtime
pub fn run(config: config::Ledger, args: args::LedgerRun, wasm_dir: PathBuf) {
pub fn run(config: config::Ledger, wasm_dir: PathBuf) {
let logical_cores = num_cpus::get();
tracing::info!("Available logical cores: {}", logical_cores);

Expand All @@ -176,22 +174,6 @@ pub fn run(config: config::Ledger, args: args::LedgerRun, wasm_dir: PathBuf) {
);
tracing::info!("Using {} threads for Tokio.", tokio_threads);

if let Some(time) = args.0 {
// Sleep until start time if not yet reached
if let Ok(sleep_time) =
time.0.signed_duration_since(Utc::now()).to_std()
{
if !sleep_time.is_zero() {
tracing::info!(
"Waiting ledger start time: {:?}, time left: {:?}",
time,
sleep_time
);
std::thread::sleep(sleep_time)
}
}
}

// Configure number of threads for rayon (used in `par_iter` when running
// VPs)
rayon::ThreadPoolBuilder::new()
Expand Down

0 comments on commit 4054816

Please sign in to comment.