Skip to content

Commit

Permalink
add api logic
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Aug 16, 2023
1 parent 48661b4 commit ae690fb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions beacon_node/http_api/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use beacon_chain::{
};
use eth2::types::{self as api_types, EndpointVersion, SkipRandaoVerification};
use ssz::Encode;
use types::*;
use warp::{
hyper::{Body, Response},
Reply,
Expand Down Expand Up @@ -80,7 +79,7 @@ pub async fn determine_and_produce_block_json<T: BeaconChainTypes>(
.await
.unwrap()
{
BeaconBlockAndStateResponse::Full((block, state)) => {
BeaconBlockAndStateResponse::Full((block, _)) => {
let fork_name = block
.to_ref()
.fork_name(&chain.spec)
Expand All @@ -89,11 +88,11 @@ pub async fn determine_and_produce_block_json<T: BeaconChainTypes>(
fork_versioned_response(endpoint_version, fork_name, block)
.map(|response| warp::reply::json(&response).into_response())
.map(|res| add_consensus_version_header(res, fork_name))
.map(|res| add_execution_payload_blinded_header(res, true))
.map(|res| add_execution_payload_blinded_header(res, false))
.map(|res: Response<Body>| add_execution_payload_value_header(res, 0))
// TODO
}
BeaconBlockAndStateResponse::Blinded((block, state)) => {
BeaconBlockAndStateResponse::Blinded((block, _)) => {
let fork_name = block
.to_ref()
.fork_name(&chain.spec)
Expand All @@ -110,7 +109,6 @@ pub async fn determine_and_produce_block_json<T: BeaconChainTypes>(
}

pub async fn determine_and_produce_block_ssz<T: BeaconChainTypes>(
endpoint_version: EndpointVersion,
chain: Arc<BeaconChain<T>>,
slot: Slot,
query: api_types::ValidatorBlocksQuery,
Expand All @@ -125,7 +123,7 @@ pub async fn determine_and_produce_block_ssz<T: BeaconChainTypes>(
let randao_verification = get_randao_verification(&query, randao_reveal.is_infinity())?;

// TODO: block value
let (block_ssz, fork_name, block_value) = match chain
let (block_ssz, fork_name, block_value, blinded) = match chain
.determine_and_produce_block_with_verification(
randao_reveal,
slot,
Expand All @@ -135,21 +133,21 @@ pub async fn determine_and_produce_block_ssz<T: BeaconChainTypes>(
.await
.unwrap()
{
BeaconBlockAndStateResponse::Full((block, state)) => {
BeaconBlockAndStateResponse::Full((block, _)) => {
let fork_name = block
.to_ref()
.fork_name(&chain.spec)
.map_err(inconsistent_fork_rejection)?;

(block.as_ssz_bytes(), fork_name, 0)
(block.as_ssz_bytes(), fork_name, 0, false)
}
BeaconBlockAndStateResponse::Blinded((block, state)) => {
BeaconBlockAndStateResponse::Blinded((block, _)) => {
let fork_name = block
.to_ref()
.fork_name(&chain.spec)
.map_err(inconsistent_fork_rejection)?;

(block.as_ssz_bytes(), fork_name, 0)
(block.as_ssz_bytes(), fork_name, 0, true)
}
};

Expand Down

0 comments on commit ae690fb

Please sign in to comment.