feat(network): add an extra ergonomic method for n2c chainsync (#439)

This commit is contained in:
Pi Lanningham 2024-04-16 18:04:07 -04:00 committed by GitHub
parent 97a32c9af5
commit 1724f6acf0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -280,6 +280,20 @@ where
self.recv_while_can_await().await
}
/// Either requests the next block, or waits for one to become available.
///
/// # Errors
///
/// Returns an error if the message cannot be sent, or if the inbound
/// message is invalid
pub async fn request_or_await_next(&mut self) -> Result<NextResponse<O>, ClientError> {
if self.has_agency() {
self.request_next().await
} else {
self.recv_while_must_reply().await
}
}
/// Attempt to intersect the chain at its origin (genesis block)
///
/// # Errors