Skip to content

Commit

Permalink
subblock height check
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Sep 3, 2024
1 parent c382a38 commit 15ca997
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1077,18 +1077,24 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef,
}

def processSubblock(subBlockInfo: SubBlockInfo, hr: ErgoHistoryReader, remote: ConnectedPeer): Unit = {
if(subBlockInfo.valid()) {
val prevSbIdOpt = subBlockInfo.prevSubBlockId.map(bytesToId) // link to previous sub-block

prevSbIdOpt match {
case Some(prevSubBlockId) =>
log.debug(s"Processing valid sub-block ${subBlockInfo.subBlock.id} with parent sub-block ${prevSubBlockId}")
case None =>
log.debug(s"Processing valid sub-block ${subBlockInfo.subBlock.id} with parent block ${subBlockInfo.subBlock.parentId}")
val subBlockHeader = subBlockInfo.subBlock
if (subBlockHeader.height == hr.fullBlockHeight + 1) {
if (subBlockInfo.valid()) {
val prevSbIdOpt = subBlockInfo.prevSubBlockId.map(bytesToId) // link to previous sub-block

prevSbIdOpt match {
case Some(prevSubBlockId) =>
log.debug(s"Processing valid sub-block ${subBlockHeader.id} with parent sub-block ${prevSubBlockId}")
case None =>
log.debug(s"Processing valid sub-block ${subBlockHeader.id} with parent block ${subBlockHeader.parentId}")
}
} else {
log.warn(s"Sub-block ${subBlockHeader.id} is invalid")
penalizeMisbehavingPeer(remote)
}
} else {
log.warn(s"Sub-block ${subBlockInfo.subBlock.id} is invalid")
penalizeMisbehavingPeer(remote)
log.info(s"Got sub-block for height ${subBlockHeader.height}, while height of our best full-block is ${hr.fullBlockHeight}")
// just ignore the subblock
}
}

Expand Down

0 comments on commit 15ca997

Please sign in to comment.