Pass vec to range sync batch (#5710)

* Pass vec to range sync batch
This commit is contained in:
Lion - dapplion
2024-06-27 20:21:40 +02:00
committed by GitHub
parent f14f21f37b
commit 784ef5fb43
5 changed files with 46 additions and 85 deletions

View File

@@ -369,7 +369,7 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
batch_id: BatchId,
peer_id: &PeerId,
request_id: Id,
beacon_block: Option<RpcBlock<T::EthSpec>>,
blocks: Vec<RpcBlock<T::EthSpec>>,
) -> Result<ProcessResult, BackFillError> {
// check if we have this batch
let batch = match self.batches.get_mut(&batch_id) {
@@ -392,20 +392,14 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
}
};
if let Some(block) = beacon_block {
// This is not a stream termination, simply add the block to the request
if let Err(e) = batch.add_block(block) {
self.fail_sync(BackFillError::BatchInvalidState(batch_id, e.0))?;
}
Ok(ProcessResult::Successful)
} else {
{
// A stream termination has been sent. This batch has ended. Process a completed batch.
// Remove the request from the peer's active batches
self.active_requests
.get_mut(peer_id)
.map(|active_requests| active_requests.remove(&batch_id));
match batch.download_completed() {
match batch.download_completed(blocks) {
Ok(received) => {
let awaiting_batches =
self.processing_target.saturating_sub(batch_id) / BACKFILL_EPOCHS_PER_BATCH;