Avoid pruning when there are no forks (#1268)

This commit is contained in:
Paul Hauner 2020-06-15 19:04:27 +10:00 committed by GitHub
parent 7818447fd2
commit 6b8c96662f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,11 @@ pub trait Migrate<E: EthSpec>: Send + Sync + 'static {
new_finalized_block_hash: SignedBeaconBlockHash, new_finalized_block_hash: SignedBeaconBlockHash,
new_finalized_slot: Slot, new_finalized_slot: Slot,
) -> Result<(), BeaconChainError> { ) -> Result<(), BeaconChainError> {
// There will never be any blocks to prune if there is only a single head in the chain.
if head_tracker.heads().len() == 1 {
return Ok(());
}
let old_finalized_slot = store let old_finalized_slot = store
.get_block(&old_finalized_block_hash.into())? .get_block(&old_finalized_block_hash.into())?
.ok_or_else(|| BeaconChainError::MissingBeaconBlock(old_finalized_block_hash.into()))? .ok_or_else(|| BeaconChainError::MissingBeaconBlock(old_finalized_block_hash.into()))?