mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-24 15:02:17 +01:00
Refactor to not throw an exception is node is already syncing (#4970)
* Refactor to not throw an exception is node is already syncing * Refactor method name
This commit is contained in:
parent
3bc89c680f
commit
76fc3cdc41
1 changed files with 19 additions and 3 deletions
|
@ -513,9 +513,25 @@ object NodeUnitTest extends P2PLogger {
|
|||
import system.dispatcher
|
||||
for {
|
||||
syncing <- node.chainApiFromDb().flatMap(_.isSyncing())
|
||||
_ = require(
|
||||
!syncing,
|
||||
s"Cannot start syncing neutrino node when previous sync is ongoing")
|
||||
newNode <- {
|
||||
if (syncing) {
|
||||
//do nothing as we are already syncing
|
||||
logger.info(
|
||||
s"Node is already syncing, skipping initiating a new sync.")
|
||||
Future.successful(node)
|
||||
} else {
|
||||
neutrinoNodeSyncHelper(node, bitcoind)
|
||||
}
|
||||
}
|
||||
} yield newNode
|
||||
}
|
||||
|
||||
private def neutrinoNodeSyncHelper(
|
||||
node: NeutrinoNode,
|
||||
bitcoind: BitcoindRpcClient)(implicit
|
||||
system: ActorSystem): Future[NeutrinoNode] = {
|
||||
import system.dispatcher
|
||||
for {
|
||||
_ <- node.sync()
|
||||
syncing <- node.chainApiFromDb().flatMap(_.isSyncing())
|
||||
_ = require(syncing)
|
||||
|
|
Loading…
Add table
Reference in a new issue