POST /eth/v2/beacon/pool/attestations bugfixes (#6867)

This commit is contained in:
Eitan Seri-Levi
2025-01-31 03:20:44 +03:00
committed by GitHub
parent d47b3e3e43
commit 276eda3dfe
15 changed files with 160 additions and 63 deletions

View File

@@ -17,6 +17,7 @@ pub mod types;
use self::mixin::{RequestAccept, ResponseOptional};
use self::types::{Error as ResponseError, *};
use derivative::Derivative;
use either::Either;
use futures::Stream;
use futures_util::StreamExt;
use lighthouse_network::PeerId;
@@ -1324,9 +1325,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/pool/attestations`
pub async fn post_beacon_pool_attestations_v2(
pub async fn post_beacon_pool_attestations_v2<E: EthSpec>(
&self,
attestations: &[SingleAttestation],
attestations: Either<Vec<Attestation<E>>, Vec<SingleAttestation>>,
fork_name: ForkName,
) -> Result<(), Error> {
let mut path = self.eth_path(V2)?;
@@ -1337,13 +1338,26 @@ impl BeaconNodeHttpClient {
.push("pool")
.push("attestations");
self.post_with_timeout_and_consensus_header(
path,
&attestations,
self.timeouts.attestation,
fork_name,
)
.await?;
match attestations {
Either::Right(attestations) => {
self.post_with_timeout_and_consensus_header(
path,
&attestations,
self.timeouts.attestation,
fork_name,
)
.await?;
}
Either::Left(attestations) => {
self.post_with_timeout_and_consensus_header(
path,
&attestations,
self.timeouts.attestation,
fork_name,
)
.await?;
}
};
Ok(())
}