Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mithril-signer/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ pub struct Configuration {

/// The maximum number of roll forwards during a poll of the block streamer when importing transactions.
pub cardano_transactions_block_streamer_max_roll_forwards_per_poll: usize,

/// Preloading refresh interval in seconds
pub preloading_refresh_interval: u64,
}

impl Configuration {
Expand Down Expand Up @@ -153,6 +156,7 @@ impl Configuration {
enable_transaction_pruning: false,
transactions_import_block_chunk_size: BlockNumber(1000),
cardano_transactions_block_streamer_max_roll_forwards_per_poll: 1000,
preloading_refresh_interval: 60,
}
}

Expand Down
23 changes: 17 additions & 6 deletions mithril-signer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::{CommandFactory, Parser, Subcommand};
use config::{Map, Value};

use slog::{o, Drain, Level, Logger};
use slog_scope::{crit, debug};
use slog_scope::{crit, debug, info};
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -80,6 +80,11 @@ pub struct Args {
/// Will be ignored on (pre)production networks.
#[clap(long)]
allow_unparsable_block: bool,

/// Preloading refresh interval in seconds
// TODO: Replace the default value to 43200 (12 hours) once the Cardano transactions is activated on mainnet
#[clap(long, env = "PRELOADING_REFRESH_INTERVAL", default_value_t = 7200)]
preloading_refresh_interval: u64,
}

impl Args {
Expand Down Expand Up @@ -184,7 +189,17 @@ async fn main() -> StdResult<()> {
.map(|_| None)
});

let preload_task = tokio::spawn(async move { cardano_transaction_preloader.preload().await });
join_set.spawn(async move {
let refresh_interval = config.preloading_refresh_interval;
let mut interval = tokio::time::interval(Duration::from_secs(refresh_interval));
loop {
interval.tick().await;
if let Err(err) = cardano_transaction_preloader.preload().await {
crit!("🔥 Cardano transactions preloader failed: {err:?}");
}
info!("⟳ Next Preload Cardano Transactions will start in {refresh_interval} s",);
}
});

let (metrics_server_shutdown_tx, metrics_server_shutdown_rx) = oneshot::channel();
if config.enable_metrics_server {
Expand Down Expand Up @@ -239,10 +254,6 @@ async fn main() -> StdResult<()> {
.send(())
.map_err(|e| anyhow!("Metrics server shutdown signal could not be sent: {e:?}"))?;

if !preload_task.is_finished() {
preload_task.abort();
}

join_set.shutdown().await;

debug!("Stopping"; "shutdown_reason" => shutdown_reason);
Expand Down
1 change: 1 addition & 0 deletions mithril-test-lab/mithril-end-to-end/src/mithril/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl Signer {
),
("ERA_READER_ADAPTER_PARAMS", &era_reader_adapter_params),
("TRANSACTIONS_IMPORT_BLOCK_CHUNK_SIZE", "150"),
("PRELOADING_REFRESH_INTERVAL", "10"),
]);
if signer_config.enable_certification {
env.insert(
Expand Down