Small Readability Improvement in Networking Code (#5098)
This commit is contained in:
parent
712f5aba73
commit
02d1f36090
@ -101,11 +101,10 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
|
|||||||
fn build_request_and_send(
|
fn build_request_and_send(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: Id,
|
id: Id,
|
||||||
already_downloaded: bool,
|
|
||||||
cx: &SyncNetworkContext<T>,
|
cx: &SyncNetworkContext<T>,
|
||||||
) -> Result<(), LookupRequestError> {
|
) -> Result<(), LookupRequestError> {
|
||||||
// Check if request is necessary.
|
// 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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,19 +114,18 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
cx: &SyncNetworkContext<T>,
|
cx: &SyncNetworkContext<T>,
|
||||||
) -> Result<(), LookupRequestError> {
|
) -> Result<(), LookupRequestError> {
|
||||||
let block_root = self.block_root();
|
|
||||||
let block_already_downloaded = self.block_already_downloaded();
|
let block_already_downloaded = self.block_already_downloaded();
|
||||||
let blobs_already_downloaded = self.blobs_already_downloaded();
|
let blobs_already_downloaded = self.blobs_already_downloaded();
|
||||||
|
|
||||||
if block_already_downloaded && blobs_already_downloaded {
|
if !block_already_downloaded {
|
||||||
trace!(cx.log, "Lookup request already completed"; "block_root"=> ?block_root);
|
self.block_request_state
|
||||||
return Ok(());
|
.build_request_and_send(self.id, cx)?;
|
||||||
}
|
}
|
||||||
let id = self.id;
|
if !blobs_already_downloaded {
|
||||||
self.block_request_state
|
self.blob_request_state
|
||||||
.build_request_and_send(id, block_already_downloaded, cx)?;
|
.build_request_and_send(self.id, cx)?;
|
||||||
self.blob_request_state
|
}
|
||||||
.build_request_and_send(id, blobs_already_downloaded, cx)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a `CachedChild`, which is a wrapper around a `RpcBlock` that is either:
|
/// Returns a `CachedChild`, which is a wrapper around a `RpcBlock` that is either:
|
||||||
|
Loading…
Reference in New Issue
Block a user