Add chain_id in range syncing to avoid wrong dispatching of batch results (#1037)

This commit is contained in:
divma
2020-04-22 06:17:56 -05:00
committed by GitHub
parent 2b6b2354e4
commit 2469bde6b1
6 changed files with 75 additions and 28 deletions

View File

@@ -35,7 +35,7 @@
use super::block_processor::{spawn_block_processor, BatchProcessResult, ProcessId};
use super::network_context::SyncNetworkContext;
use super::range_sync::{BatchId, RangeSync};
use super::range_sync::{BatchId, ChainId, RangeSync};
use crate::router::processor::PeerSyncInfo;
use crate::service::NetworkMessage;
use beacon_chain::{BeaconChain, BeaconChainTypes, BlockProcessingOutcome};
@@ -99,6 +99,7 @@ pub enum SyncMessage<T: EthSpec> {
/// A batch has been processed by the block processor thread.
BatchProcessed {
chain_id: ChainId,
batch_id: BatchId,
downloaded_blocks: Vec<SignedBeaconBlock<T>>,
result: BatchProcessResult,
@@ -731,12 +732,14 @@ impl<T: BeaconChainTypes> Future for SyncManager<T> {
self.inject_error(peer_id, request_id);
}
SyncMessage::BatchProcessed {
chain_id,
batch_id,
downloaded_blocks,
result,
} => {
self.range_sync.handle_block_process_result(
&mut self.network,
chain_id,
batch_id,
downloaded_blocks,
result,