Skip to content

Commit

Permalink
Fix StateUpdate removal on rollback (#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Nazarov authored Sep 24, 2021
1 parent acd2455 commit 102a53a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BlockchainUpdates(private val context: Context) extends Extension with Sco
if (lastUpdateId != lastBlockId)
throw new IllegalStateException(s"Last update ID $lastUpdateId does not match last block ID $lastBlockId at height $nodeHeight")

log.info(s"BlockchainUpdates startup check successful at height $extensionHeight")
log.info(s"BlockchainUpdates startup check successful at height $nodeHeight")

grpcServer.start()
log.info(s"BlockchainUpdates extension started gRPC API on port ${settings.grpcPort}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Repo(dbDirectory: String, blocksApi: CommonBlocksApi)(implicit s: Schedule
log.debug(s"Rolling back to $toHeight")
var buf: List[BlockAppended] = Nil
Using(rw.newIterator) { iter =>
iter.seek(Ints.toByteArray(toHeight + 1))
iter.seek(keyForHeight(toHeight + 1))
while (iter.hasNext) {
val e = iter.next()
val height = Ints.fromByteArray(e.getKey)
Expand All @@ -110,7 +110,7 @@ class Repo(dbDirectory: String, blocksApi: CommonBlocksApi)(implicit s: Schedule
(1 to buf.size).foreach { offset =>
val height = toHeight + offset
log.debug(s"Deleting update at $height")
rw.delete(Ints.toByteArray(height))
rw.delete(keyForHeight(height))
}

buf
Expand Down

0 comments on commit 102a53a

Please sign in to comment.