diff --git a/atoma-sui/src/subscriber.rs b/atoma-sui/src/subscriber.rs index e4596f14..30b269b0 100644 --- a/atoma-sui/src/subscriber.rs +++ b/atoma-sui/src/subscriber.rs @@ -18,8 +18,6 @@ use tracing::{error, info, instrument, trace}; const DB_MODULE_NAME: &str = "db"; /// The duration to wait for new events in seconds, if there are no new events. const DURATION_TO_WAIT_FOR_NEW_EVENTS_IN_MILLIS: u64 = 100; -/// The amount of main loop iterations in order to update the cursor file. -const CURSOR_FILE_UPDATE_ITERATIONS: u64 = 10; pub(crate) type Result = std::result::Result; @@ -149,7 +147,6 @@ impl SuiEventSubscriber { ); let mut cursor = read_cursor_from_toml_file(&self.config.cursor_path())?; - let mut cursor_update_iteration_count = 0; loop { tokio::select! { page = client.event_api().query_events(self.filter.clone(), cursor, limit, false) => { @@ -169,9 +166,6 @@ impl SuiEventSubscriber { } }; cursor = next_cursor; - if cursor_update_iteration_count % CURSOR_FILE_UPDATE_ITERATIONS == 0 { - write_cursor_to_toml_file(cursor, &self.config.cursor_path())?; - } for sui_event in data { let event_name = sui_event.type_.name; @@ -216,10 +210,11 @@ impl SuiEventSubscriber { // NOTE: `AtomaEvent` didn't match any known event, so we skip it. } } - cursor_update_iteration_count += 1; } if !has_next_page { + // Update the cursor file with the current cursor + write_cursor_to_toml_file(cursor, &self.config.cursor_path())?; // No new events to read, so let's wait for a while trace!( target = "atoma-sui-subscriber",