Skip to content

Commit 778bcf8

Browse files
authored
ETCM-987: Latest block not found bug (#1076)
1 parent 491cc4f commit 778bcf8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/FastSync.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,14 @@ class FastSync(
567567

568568
// TODO [ETCM-676]: Move to blockchain and make sure it's atomic
569569
private def discardLastBlocks(startBlock: BigInt, blocksToDiscard: Int): Unit = {
570+
// TODO (maybe ETCM-77): Manage last checkpoint number too
571+
appStateStorage.putBestBlockNumber((startBlock - blocksToDiscard - 1).max(0)).commit()
572+
570573
(startBlock to ((startBlock - blocksToDiscard).max(1)) by -1).foreach { n =>
571574
blockchainReader.getBlockHeaderByNumber(n).foreach { headerToRemove =>
572575
blockchain.removeBlock(headerToRemove.hash, withState = false)
573576
}
574577
}
575-
// TODO (maybe ETCM-77): Manage last checkpoint number too
576-
appStateStorage.putBestBlockNumber((startBlock - blocksToDiscard - 1).max(0)).commit()
577578
}
578579

579580
private def validateHeader(header: BlockHeader, peer: Peer): Either[HeaderProcessingResult, BlockHeader] = {

src/main/scala/io/iohk/ethereum/domain/BlockchainReader.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class BlockchainReader(
180180

181181
/** Returns a block hash given a block number
182182
*
183-
* @param number Number of the searchead block
183+
* @param number Number of the searched block
184184
* @return Block hash if found
185185
*/
186186
private def getHashByBlockNumber(number: BigInt): Option[ByteString] =

0 commit comments

Comments
 (0)