mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 03:30:38 +00:00
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(
|
||||
&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(());
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user