Skip to content

Commit f92ee1f

Browse files
Update BlockFetcherState with suggestion from review
Co-authored-by: Anastasiia Pushkina <[email protected]>
1 parent c2f78a3 commit f92ee1f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/BlockFetcherState.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ case class BlockFetcherState(
129129
)
130130
}
131131

132-
private def checkConsistencyWithReadyBlocks(headers: Seq[BlockHeader]): Boolean = {
133-
if (waitingHeaders.isEmpty) {
134-
(readyBlocks.lastOption.map(_.header), headers.headOption).mapN(_ isParentOf _).getOrElse(true)
135-
} else true
136-
}
132+
private def checkConsistencyWithReadyBlocks(headers: Seq[BlockHeader]): Boolean = {
133+
(readyBlocks, headers) match {
134+
case (_ :+ last, head +: _) if waitingHeaders.isEmpty => last.header isParentOf head
135+
case _ => true
136+
}
137137

138138
def validateNewBlockHashes(hashes: Seq[BlockHash]): Either[String, Seq[BlockHash]] =
139139
hashes

0 commit comments

Comments
 (0)