diff --git a/src/state_listeners.rs b/src/state_listeners.rs index 7cb5bc7..8dcb685 100644 --- a/src/state_listeners.rs +++ b/src/state_listeners.rs @@ -9,6 +9,7 @@ use std::sync::{Arc, RwLock}; use std::time::Duration; use tokio_util::sync::CancellationToken; use tracing::info; +use crate::tx_senders::constants::SLOT_ERROR_THRESHOLD; pub struct ChainListener { pub current_slot: Arc, @@ -72,9 +73,15 @@ impl ChainListener { slot = stream.next() => slot, } { if let SlotUpdate::FirstShredReceived { slot, .. } = slot { + if slot > current_slot.load(Ordering::Relaxed) + SLOT_ERROR_THRESHOLD { + continue + } current_slot.store(slot, Ordering::Relaxed); } if let SlotUpdate::Completed { slot, .. } = slot { + if slot > current_slot.load(Ordering::Relaxed) + SLOT_ERROR_THRESHOLD { + continue + } current_slot.store(slot + 1, Ordering::Relaxed); } } diff --git a/src/tx_senders/constants.rs b/src/tx_senders/constants.rs index 795152d..c3c7993 100644 --- a/src/tx_senders/constants.rs +++ b/src/tx_senders/constants.rs @@ -8,3 +8,5 @@ pub const JITO_RPC_URL: &str = "https://mainnet.block-engine.jito.wtf:443/api/v1 pub const NOZOMI_TIP: &str = "TEMPaMeCRFAS9EKF53Jd6KpHxgL47uWLcpFArU1Fanq"; pub const MIN_TIP_AMOUNT: u64 = 1_000_000; + +pub const SLOT_ERROR_THRESHOLD: u64 = 5; \ No newline at end of file