-
Notifications
You must be signed in to change notification settings - Fork 1.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
feat: add helper stream type for finalized notifications #14111
base: main
Are you sure you want to change the base?
Conversation
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 is a great start
left a few suggestions
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.
great, this lgtm!
only need to take a final closer look
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.
nice work, I have a few smol suggestions
#[pin] | ||
canon_stream: CanonStateNotificationStream<N>, | ||
#[pin] | ||
finalized_stream: ForkChoiceStream<SealedHeader<alloy_consensus::Header>>, |
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.
we need to replace the concrete header types with
finalized_stream: ForkChoiceStream<SealedHeader<alloy_consensus::Header>>, | |
finalized_stream: ForkChoiceStream<SealedHeaderFor<N>>, |
fn try_match( | ||
buffered_notification: &Option<CanonStateNotification<N>>, | ||
buffered_finalization: &Option<SealedHeader<alloy_consensus::Header>>, | ||
) -> Option<CanonStateNotification<N>> { | ||
match (buffered_notification, buffered_finalization) { | ||
(Some(notification), Some(finalized_header)) | ||
if notification.tip().hash() == finalized_header.hash() => | ||
{ | ||
Some(notification.clone()) | ||
} | ||
_ => None, | ||
} |
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'd like to inline this function so that we can .take the notification instead.
so we can move this inside the poll fn
Poll::Ready(None) => return Poll::Ready(None), | ||
Poll::Pending => {} | ||
} | ||
|
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.
let's add a check here that breaks if one Option is none
|
||
// Check if we have a matching pair using the projected fields | ||
if let Some(notification) = | ||
Self::try_match(this.buffered_notification, this.buffered_finalization) |
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 check can be simplified by checking
buffered.as_ref.map(|n|n.tip) == header.as_ref.map() {
header.take();
return buffered.take()
}
Closes #14063