mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Reduce calls to network channel (#4863)
## Issue Addressed N/A ## Proposed Changes Sends blocks and blobs from http_api to the network channel for publishing in a single network channel send. This is to avoid overhead of multiple calls. Also adds a metric for rpc blob retrieval duration.
This commit is contained in:
@@ -85,19 +85,17 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
|
||||
}
|
||||
SignedBeaconBlock::Deneb(_) => {
|
||||
crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block.clone()))
|
||||
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
|
||||
let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block.clone())];
|
||||
if let Some(signed_blobs) = blobs_opt {
|
||||
for (blob_index, blob) in signed_blobs.into_iter().enumerate() {
|
||||
crate::publish_pubsub_message(
|
||||
&sender,
|
||||
PubsubMessage::BlobSidecar(Box::new((blob_index as u64, blob))),
|
||||
)
|
||||
.map_err(|_| {
|
||||
BlockError::BeaconChainError(BeaconChainError::UnableToPublish)
|
||||
})?;
|
||||
pubsub_messages.push(PubsubMessage::BlobSidecar(Box::new((
|
||||
blob_index as u64,
|
||||
blob,
|
||||
))));
|
||||
}
|
||||
}
|
||||
crate::publish_pubsub_messages(&sender, pubsub_messages)
|
||||
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user