-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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 issue #1096 #1153
Fix issue #1096 #1153
Conversation
while state.db().last_consensus_index().unwrap() != SequenceNumber::from(1) { | ||
tokio::time::sleep(std::time::Duration::from_millis(10)).await; | ||
} |
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.
Is there a better way to do that actually? Something like the notify_read
we had in Narwhal perhaps
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.
The notify_read
is in typed_store
and you should be able to use it anywhere you have a Store
. But it is fundamentally an async API ..
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.
You will need to build a notification infra like for the batches to do that. Probably, this will be necessary as new consensus items should trigger execution out of band, but we will cross that bridge when we get to it.
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.
I think this may be what you're looking for:
use futures::future::poll_fn;
use futures::task::{Context, Poll};
fn barrier_last_seq_num(_cx: &mut Context<'_>) -> Poll<()> {
match state.db().last_consensus_index() {
Some(val) if val == SequenceNumber::from(1) => Poll::Ready(()),
_ => Poll::Pending,
}
}
let barrier= poll_fn(barrier_last_seq_num);
...
// later at point of use
barrier.await
while state.db().last_consensus_index().unwrap() != SequenceNumber::from(1) { | ||
tokio::time::sleep(std::time::Duration::from_millis(10)).await; | ||
} |
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.
The notify_read
is in typed_store
and you should be able to use it anywhere you have a Store
. But it is fundamentally an async API ..
I tried but couldn't make it work. I keep a marker to your snipped for later (when we will need such facility for other things that testing) |
Fix issue #1096