mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-20 14:03:11 +01:00
Fix rescan to fetch blocks during scan (#2540)
This commit is contained in:
parent
7cce23abf7
commit
cba90e5c2b
2 changed files with 9 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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]] = {
|
||||
|
|
Loading…
Add table
Reference in a new issue