Small Readability Improvement in Networking Code (#5098)

This commit is contained in:
ethDreamer 2024-01-23 12:08:57 +08:00 committed by GitHub
parent 712f5aba73
commit 02d1f36090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 11 deletions

View File

@ -101,11 +101,10 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
fn build_request_and_send(
&mut self,
id: Id,
already_downloaded: bool,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
// Check if request is necessary.
if already_downloaded || !matches!(self.get_state().state, State::AwaitingDownload) {
if !matches!(self.get_state().state, State::AwaitingDownload) {
return Ok(());
}

View File

@ -114,19 +114,18 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
&mut self,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
let block_root = self.block_root();
let block_already_downloaded = self.block_already_downloaded();
let blobs_already_downloaded = self.blobs_already_downloaded();
if block_already_downloaded && blobs_already_downloaded {
trace!(cx.log, "Lookup request already completed"; "block_root"=> ?block_root);
return Ok(());
if !block_already_downloaded {
self.block_request_state
.build_request_and_send(self.id, cx)?;
}
let id = self.id;
self.block_request_state
.build_request_and_send(id, block_already_downloaded, cx)?;
self.blob_request_state
.build_request_and_send(id, blobs_already_downloaded, cx)
if !blobs_already_downloaded {
self.blob_request_state
.build_request_and_send(self.id, cx)?;
}
Ok(())
}
/// Returns a `CachedChild`, which is a wrapper around a `RpcBlock` that is either: