Ensure batches align to epoch boundaries (#1021)

* Ensure batches align to epoch boundaries

* Clean up range_sync logs
This commit is contained in:
divma
2020-04-26 23:18:09 -05:00
committed by GitHub
parent a50ade3ffc
commit fa8154e3da
4 changed files with 87 additions and 63 deletions

View File

@@ -1,4 +1,4 @@
use super::chain::BLOCKS_PER_BATCH;
use super::chain::EPOCHS_PER_BATCH;
use eth2_libp2p::rpc::methods::*;
use eth2_libp2p::rpc::RequestId;
use eth2_libp2p::PeerId;
@@ -76,7 +76,10 @@ impl<T: EthSpec> Batch<T> {
pub fn to_blocks_by_range_request(&self) -> BlocksByRangeRequest {
BlocksByRangeRequest {
start_slot: self.start_slot.into(),
count: std::cmp::min(BLOCKS_PER_BATCH, self.end_slot.sub(self.start_slot).into()),
count: std::cmp::min(
T::slots_per_epoch() * EPOCHS_PER_BATCH,
self.end_slot.sub(self.start_slot).into(),
),
step: 1,
}
}