From 7c112b8a907a5d6d6123f437126753d82aa58fd0 Mon Sep 17 00:00:00 2001 From: rorp Date: Wed, 24 Aug 2022 03:42:53 -0700 Subject: [PATCH] Fix rescan for existing wallets (#4656) --- .../bitcoins/node/networking/peer/DataMessageHandler.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala b/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala index 527d05a29f..e6f296c7c3 100644 --- a/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala +++ b/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala @@ -688,10 +688,14 @@ case class DataMessageHandler( creationTimeHeight <- creationTimeHeightF filterCount <- filterCountF } yield { + //filterHeightOpt contains the height of the last filter of the last batch + //so if we want to start syncing filters from the correct height we need to + //decrease the computed height + val height = Math.max(0, creationTimeHeight - 1) //want to choose the maximum out of these too //if our internal chainstate filter count is > creationTimeHeight //we just want to start syncing from our last seen filter - Some(Math.max(creationTimeHeight, filterCount)) + Some(Math.max(height, filterCount)) } case None => Future.successful(None)