mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Add more
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use beacon_chain::{BeaconBlockResponse, BeaconBlockResponseWrapper, BlockProductionError};
|
||||
use eth2::types::{BlockContents, FullBlockContents, ProduceBlockV3Response};
|
||||
use types::{EthSpec, ForkName};
|
||||
use types::{EthSpec, FeatureName, ForkName};
|
||||
type Error = warp::reject::Rejection;
|
||||
|
||||
pub fn build_block_contents<E: EthSpec>(
|
||||
@@ -11,11 +11,8 @@ pub fn build_block_contents<E: EthSpec>(
|
||||
BeaconBlockResponseWrapper::Blinded(block) => {
|
||||
Ok(ProduceBlockV3Response::Blinded(block.block))
|
||||
}
|
||||
BeaconBlockResponseWrapper::Full(block) => match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Bellatrix | ForkName::Capella => Ok(
|
||||
ProduceBlockV3Response::Full(FullBlockContents::Block(block.block)),
|
||||
),
|
||||
ForkName::Deneb | ForkName::Electra => {
|
||||
BeaconBlockResponseWrapper::Full(block) => {
|
||||
if fork_name.has_feature(FeatureName::Deneb) {
|
||||
let BeaconBlockResponse {
|
||||
block,
|
||||
state: _,
|
||||
@@ -37,7 +34,11 @@ pub fn build_block_contents<E: EthSpec>(
|
||||
blobs,
|
||||
}),
|
||||
))
|
||||
} else {
|
||||
Ok(ProduceBlockV3Response::Full(FullBlockContents::Block(
|
||||
block.block,
|
||||
)))
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ use tokio::sync::mpsc::UnboundedSender;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
AbstractExecPayload, BeaconBlockRef, BlobSidecarList, EthSpec, ExecPayload, ExecutionBlockHash,
|
||||
ForkName, FullPayload, FullPayloadBellatrix, Hash256, SignedBeaconBlock,
|
||||
FeatureName, ForkName, FullPayload, FullPayloadBellatrix, Hash256, SignedBeaconBlock,
|
||||
SignedBlindedBeaconBlock, VariableList,
|
||||
};
|
||||
use warp::http::StatusCode;
|
||||
@@ -77,28 +77,22 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
|
||||
info!(log, "Signed block published to network via HTTP API"; "slot" => block.slot(), "publish_delay" => ?publish_delay);
|
||||
|
||||
match block.as_ref() {
|
||||
SignedBeaconBlock::Base(_)
|
||||
| SignedBeaconBlock::Altair(_)
|
||||
| SignedBeaconBlock::Bellatrix(_)
|
||||
| SignedBeaconBlock::Capella(_) => {
|
||||
crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block))
|
||||
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
|
||||
}
|
||||
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Electra(_) => {
|
||||
let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block)];
|
||||
if let Some(blob_sidecars) = blobs_opt {
|
||||
for (blob_index, blob) in blob_sidecars.into_iter().enumerate() {
|
||||
pubsub_messages.push(PubsubMessage::BlobSidecar(Box::new((
|
||||
blob_index as u64,
|
||||
blob,
|
||||
))));
|
||||
}
|
||||
if block.has_feature(FeatureName::Deneb) {
|
||||
let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block)];
|
||||
if let Some(blob_sidecars) = blobs_opt {
|
||||
for (blob_index, blob) in blob_sidecars.into_iter().enumerate() {
|
||||
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))?;
|
||||
}
|
||||
};
|
||||
crate::publish_pubsub_messages(&sender, pubsub_messages)
|
||||
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
|
||||
} else {
|
||||
crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block))
|
||||
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user