Fix: Off-by-one error during rewind.
This commit is contained in:
parent
5dd0df7619
commit
c60119cd5a
|
@ -596,7 +596,8 @@ class CompactBlockProcessor(
|
||||||
return if (height < lowerBoundHeight) {
|
return if (height < lowerBoundHeight) {
|
||||||
lowerBoundHeight
|
lowerBoundHeight
|
||||||
} else {
|
} else {
|
||||||
rustBackend.getNearestRewindHeight(height)
|
// tricky: subtract one because we delete ABOVE this block
|
||||||
|
rustBackend.getNearestRewindHeight(height) - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ interface TransactionDao {
|
||||||
twig("[cleanup] cleanupCancelledTx found ${it.size} matching transactions to cleanup")
|
twig("[cleanup] cleanupCancelledTx found ${it.size} matching transactions to cleanup")
|
||||||
}.forEach { transactionId ->
|
}.forEach { transactionId ->
|
||||||
hasInitialMatch = true
|
hasInitialMatch = true
|
||||||
removeInvalidTransaction(transactionId)
|
removeInvalidOutboundTransaction(transactionId)
|
||||||
}
|
}
|
||||||
hasFinalMatch = findMatchingTransactionId(rawTransactionId) != null
|
hasFinalMatch = findMatchingTransactionId(rawTransactionId) != null
|
||||||
success = hasInitialMatch && !hasFinalMatch
|
success = hasInitialMatch && !hasFinalMatch
|
||||||
|
@ -445,7 +445,7 @@ interface TransactionDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
suspend fun removeInvalidTransaction(transactionId: Long): Boolean {
|
suspend fun removeInvalidOutboundTransaction(transactionId: Long): Boolean {
|
||||||
var success = false
|
var success = false
|
||||||
try {
|
try {
|
||||||
twig("[cleanup] removing invalid transactionId:$transactionId")
|
twig("[cleanup] removing invalid transactionId:$transactionId")
|
||||||
|
@ -474,7 +474,7 @@ interface TransactionDao {
|
||||||
suspend fun deleteExpired(lastHeight: Int): Int {
|
suspend fun deleteExpired(lastHeight: Int): Int {
|
||||||
var count = 0
|
var count = 0
|
||||||
findExpiredTxs(lastHeight).forEach { transactionId ->
|
findExpiredTxs(lastHeight).forEach { transactionId ->
|
||||||
if (removeInvalidTransaction(transactionId)) count++
|
if (removeInvalidOutboundTransaction(transactionId)) count++
|
||||||
}
|
}
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue