-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use tokio::time::Interval for scheduling anchor batches #563
Conversation
This leverages the time math of skipping missed ticks etc. We are only left with computing the time when we should start the first tick. For this we use chrono and then rely on Interval for the heavy lifting.
@@ -76,28 +77,42 @@ impl AnchorService { | |||
pin_mut!(shutdown_signal); | |||
|
|||
info!("anchor service started"); | |||
let period = | |||
TimeDelta::from_std(self.anchor_interval).expect("anchor interval should be in range"); | |||
let buffer = period / 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is buffer doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its the buffer time we give ourselves to actually process the batch. I'll add a comment. For 1hour it ends up being 5 minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
This leverages the time math of skipping missed ticks etc. We are only left with computing the time when we should start the first tick. For this we use chrono and then rely on Interval for the heavy lifting.