mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
Call getFilterHeaderCount async inside of nextFilterHeaderBatchRange while we are fetching our start height for fetching filters (#1327)
This commit is contained in:
parent
8a079d25d7
commit
bb347890c0
1 changed files with 5 additions and 2 deletions
|
@ -142,9 +142,10 @@ case class ChainHandler(
|
|||
throw UnknownBlockHash(s"Unknown block hash ${prevStopHash}"))
|
||||
} yield prevStopHeader.height + 1
|
||||
}
|
||||
val blockCountF = getBlockCount
|
||||
for {
|
||||
startHeight <- startHeightF
|
||||
blockCount <- getBlockCount
|
||||
blockCount <- blockCountF
|
||||
stopHeight = if (startHeight - 1 + batchSize > blockCount) blockCount
|
||||
else startHeight - 1 + batchSize
|
||||
stopBlockOpt <- getHeadersAtHeight(stopHeight).map(_.headOption)
|
||||
|
@ -162,6 +163,7 @@ case class ChainHandler(
|
|||
override def nextFilterHeaderBatchRange(
|
||||
prevStopHash: DoubleSha256DigestBE,
|
||||
batchSize: Int): Future[Option[(Int, DoubleSha256Digest)]] = {
|
||||
val filterHeaderCountF = getFilterHeaderCount
|
||||
val startHeightF = if (prevStopHash == DoubleSha256DigestBE.empty) {
|
||||
Future.successful(0)
|
||||
} else {
|
||||
|
@ -171,9 +173,10 @@ case class ChainHandler(
|
|||
throw UnknownBlockHash(s"Unknown block hash ${prevStopHash}"))
|
||||
} yield prevStopHeader.height + 1
|
||||
}
|
||||
|
||||
for {
|
||||
startHeight <- startHeightF
|
||||
filterHeaderCount <- getFilterHeaderCount
|
||||
filterHeaderCount <- filterHeaderCountF
|
||||
stopHeight = if (startHeight - 1 + batchSize > filterHeaderCount)
|
||||
filterHeaderCount
|
||||
else startHeight - 1 + batchSize
|
||||
|
|
Loading…
Add table
Reference in a new issue