mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 01:40:55 +01:00
Add some guards for when we set IBD flag to reduce false positive WARN messages (#4683)
This commit is contained in:
parent
f65b483d6f
commit
9353c41e8f
@ -143,7 +143,7 @@ case class DataMessageHandler(
|
||||
}
|
||||
// If we are not syncing or our filter batch is full, process the filters
|
||||
filterBatch = currentFilterBatch :+ filter
|
||||
(newBatch, newChainApi) <-
|
||||
(newBatch, newChainApi) <- {
|
||||
if (!newSyncing || batchSizeFull) {
|
||||
val blockFilters = filterBatch.map { filter =>
|
||||
(filter.blockHash,
|
||||
@ -157,6 +157,7 @@ case class DataMessageHandler(
|
||||
.executeOnCompactFiltersReceivedCallbacks(blockFilters)
|
||||
} yield (Vector.empty, newChainApi)
|
||||
} else Future.successful((filterBatch, chainApi))
|
||||
}
|
||||
_ <-
|
||||
if (batchSizeFull) {
|
||||
logger.info(
|
||||
@ -171,7 +172,7 @@ case class DataMessageHandler(
|
||||
}
|
||||
}
|
||||
newChainApi <- newChainApi.setSyncing(newSyncing2)
|
||||
_ <- newChainApi.setIBD(newSyncing)
|
||||
_ <- checkIBD(newChainApi)
|
||||
} yield {
|
||||
this.copy(
|
||||
chainApi = newChainApi,
|
||||
@ -717,6 +718,23 @@ case class DataMessageHandler(
|
||||
if (filterHeight == 0) 0 else filterHeight + 1)
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks if the IBD flag needs to be set from true -> false */
|
||||
private def checkIBD(chainApi: ChainApi): Future[Unit] = {
|
||||
val isSyncingF = chainApi.isSyncing()
|
||||
val isIBDF = chainApi.isIBD()
|
||||
for {
|
||||
isSyncing <- isSyncingF
|
||||
isIBD <- isIBDF
|
||||
_ <- {
|
||||
if (isIBD) {
|
||||
chainApi.setIBD(isSyncing)
|
||||
} else {
|
||||
Future.unit
|
||||
}
|
||||
}
|
||||
} yield ()
|
||||
}
|
||||
}
|
||||
|
||||
sealed trait StreamDataMessageWrapper
|
||||
|
Loading…
Reference in New Issue
Block a user