Fix: Full rescan should not go beyond the checkpoint.

Otherwise, it gets interpreted as a reorg and can throw the wallet into an infinite rewind loop.
This commit is contained in:
Kevin Gorham 2021-04-29 03:34:35 -04:00
parent 303e1da180
commit 418106538e
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
1 changed files with 4 additions and 2 deletions

View File

@ -594,8 +594,10 @@ class CompactBlockProcessor(
}
suspend fun getNearestRewindHeight(height: Int): Int {
return if (height < lowerBoundHeight) {
lowerBoundHeight
// TODO: add a concept of original checkpoint height to the processor. For now, derive it
val originalCheckpoint = lowerBoundHeight + MAX_REORG_SIZE + 2 // add one because we already have the checkpoint. Add one again because we delete ABOVE the block
return if (height < originalCheckpoint) {
originalCheckpoint
} else {
// tricky: subtract one because we delete ABOVE this block
rustBackend.getNearestRewindHeight(height) - 1