Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions services/publisher/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@ pub struct Cli {
help = "Enable metrics"
)]
pub use_metrics: bool,
/// Historical gap processing interval in seconds
#[arg(
long,
value_name = "HISTORY_INTERVAL",
env = "HISTORY_INTERVAL",
default_value = "259200",
help = "Interval in seconds for processing historical gaps (default: 3 days). Set to 0 to disable."
)]
pub history_interval: u64,
}
11 changes: 9 additions & 2 deletions services/publisher/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use crate::{
publish::publish_block,
};

#[allow(clippy::too_many_arguments)]
pub async fn process_historical_gaps_periodically(
interval_secs: u64,
from_block: BlockHeight,
db: &Arc<Db>,
message_broker: &Arc<NatsMessageBroker>,
Expand All @@ -23,8 +25,13 @@ pub async fn process_historical_gaps_periodically(
shutdown: &Arc<ShutdownController>,
telemetry: &Arc<Telemetry<Metrics>>,
) -> Result<(), anyhow::Error> {
// Run every 5 hours
let mut interval = interval(Duration::from_secs(3600 * 5));
if interval_secs == 0 {
tracing::info!("Historical gap processing is disabled");
return Ok(());
}

// Run at the specified interval
let mut interval = interval(Duration::from_secs(interval_secs));

loop {
if shutdown.token().is_cancelled() {
Expand Down
1 change: 1 addition & 0 deletions services/publisher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async fn main() -> anyhow::Result<()> {
tokio::join!(
recover_tx_pointers(&db),
process_historical_gaps_periodically(
cli.history_interval,
cli.from_block.into(),
&db,
&message_broker,
Expand Down
4 changes: 2 additions & 2 deletions services/publisher/src/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn fetch_transaction_chunk(
pool: &PgPool,
offset: i64,
) -> Result<Vec<TransactionRecord>> {
println!("Fetching transaction chunk with offset {}", offset);
tracing::info!("Fetching transaction chunk with offset {}", offset);
sqlx::query_as::<_, TransactionRecord>(
"SELECT id, block_height, tx_index
FROM transactions
Expand Down Expand Up @@ -106,7 +106,7 @@ pub async fn recover_tx_pointers(db: &Arc<Db>) -> Result<()> {
total_updated += result??;
}

println!(
tracing::info!(
"Successfully completed transaction updates. Total transactions updated: {}",
total_updated
);
Expand Down
Loading