diff --git a/wallet-test/src/test/scala/org/bitcoins/wallet/WalletUnitTest.scala b/wallet-test/src/test/scala/org/bitcoins/wallet/WalletUnitTest.scala index d50550e80e..f68931043a 100644 --- a/wallet-test/src/test/scala/org/bitcoins/wallet/WalletUnitTest.scala +++ b/wallet-test/src/test/scala/org/bitcoins/wallet/WalletUnitTest.scala @@ -150,12 +150,16 @@ class WalletUnitTest extends BitcoinSWalletTest { it should "match block filters" in { wallet: Wallet => for { height <- wallet.chainQueryApi.getFilterCount() - matched <- wallet.fetchFiltersInRange( + filtersResponse <- chainQueryApi.getFiltersBetweenHeights(startHeight = 0, + endHeight = + height) + matched <- wallet.findMatches( + filters = filtersResponse, scripts = Vector( // this is a random address which is included into the test block BitcoinAddress("n1RH2x3b3ah4TGQtgrmNAHfmad9wr8U2QY").scriptPubKey), parallelismLevel = 1 - )(heightRange = 0.to(height).toVector) + ) } yield { assert( Vector(BlockMatchingResponse(blockHash = testBlockHash, diff --git a/wallet/src/main/scala/org/bitcoins/wallet/internal/RescanHandling.scala b/wallet/src/main/scala/org/bitcoins/wallet/internal/RescanHandling.scala index 0c56366a5f..759559068c 100644 --- a/wallet/src/main/scala/org/bitcoins/wallet/internal/RescanHandling.scala +++ b/wallet/src/main/scala/org/bitcoins/wallet/internal/RescanHandling.scala @@ -111,8 +111,6 @@ private[wallet] trait RescanHandling extends WalletLogger { elements = range.toVector, f = fetchFiltersInRange(scripts, parallelismLevel), batchSize = batchSize) - - _ <- downloadAndProcessBlocks(matched.map(_.blockHash.flip)) } yield { logger.info(s"Matched ${matched.length} blocks on rescan") matched @@ -260,7 +258,7 @@ private[wallet] trait RescanHandling extends WalletLogger { } } - private[wallet] def fetchFiltersInRange( + private def fetchFiltersInRange( scripts: Vector[ScriptPubKey], parallelismLevel: Int)( heightRange: Vector[Int]): Future[Vector[BlockMatchingResponse]] = { @@ -271,6 +269,7 @@ private[wallet] trait RescanHandling extends WalletLogger { startHeight = startHeight, endHeight = endHeight) filtered <- findMatches(filtersResponse, scripts, parallelismLevel) + _ <- downloadAndProcessBlocks(filtered.map(_.blockHash.flip)) } yield { logger.info( s"Found ${filtered.length} matches from start=$startHeight to end=$endHeight") @@ -278,7 +277,7 @@ private[wallet] trait RescanHandling extends WalletLogger { } } - private def findMatches( + private[wallet] def findMatches( filters: Vector[FilterResponse], scripts: Vector[ScriptPubKey], parallelismLevel: Int): Future[Vector[BlockMatchingResponse]] = {