Skip to content

Commit

Permalink
first commit (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 authored Nov 25, 2024
1 parent 072c4a3 commit 1896a33
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions atoma-sui/src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = std::result::Result<T, SuiEventSubscriberError>;

Expand Down Expand Up @@ -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) => {
Expand All @@ -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;
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1896a33

Please sign in to comment.