diff --git a/db-commons/src/main/resources/reference.conf b/db-commons/src/main/resources/reference.conf index 832238b01e..d92cfacc78 100644 --- a/db-commons/src/main/resources/reference.conf +++ b/db-commons/src/main/resources/reference.conf @@ -48,6 +48,8 @@ bitcoin-s { # password = "" # } + # time interval for trying next set of peers in peer discovery + try-peers-interval = 1 hour } # You can configure SOCKS5 proxy to use Tor for outgoing connections diff --git a/docs/config/configuration.md b/docs/config/configuration.md index 5a998f97c0..b07d2aff3c 100644 --- a/docs/config/configuration.md +++ b/docs/config/configuration.md @@ -169,7 +169,7 @@ bitcoin-s { # initialization timeout once connected, reconnections resets this initialization-timeout = 10s # time interval for trying next set of peers in peer discovery - try-peers-interval = 12s + try-peers-interval = 1 hour # wait time for queries like getheaders etc before switching to another query-wait-time = 120s diff --git a/node/src/main/scala/org/bitcoins/node/PeerFinder.scala b/node/src/main/scala/org/bitcoins/node/PeerFinder.scala index 0fdb03dccf..32e7b35b19 100644 --- a/node/src/main/scala/org/bitcoins/node/PeerFinder.scala +++ b/node/src/main/scala/org/bitcoins/node/PeerFinder.scala @@ -113,10 +113,7 @@ case class PeerFinder( val maxPeerSearchCount: Int = 1000 - def initialDelay: FiniteDuration = { - if (getPeersFromConfig.isEmpty && getPeersFromParam.isEmpty) 0.seconds - else nodeAppConfig.tryNextPeersInterval - } + private val initialDelay: FiniteDuration = 1.minute private val isConnectionSchedulerRunning = AtomicBoolean(false) @@ -129,6 +126,7 @@ case class PeerFinder( isConnectionSchedulerRunning.compareAndSet(expect = false, update = true) ) { + logger.info(s"Querying p2p network for peers...") logger.debug(s"Cache size: ${_peerData.size}. ${_peerData.keys}") if (_peersToTry.size < 32) _peersToTry.pushAll(getPeersFromDnsSeeds) @@ -137,7 +135,7 @@ case class PeerFinder( .filterNot(p => skipPeers().contains(p) || _peerData.contains(p)) logger.debug(s"Trying next set of peers $peers") - val peersF = Future.sequence(peers.map(tryPeer)) + val peersF = Future.traverse(peers)(tryPeer) peersF.onComplete { case Success(_) => isConnectionSchedulerRunning.set(false) diff --git a/node/src/main/scala/org/bitcoins/node/config/NodeAppConfig.scala b/node/src/main/scala/org/bitcoins/node/config/NodeAppConfig.scala index c32c020274..4535bfe122 100644 --- a/node/src/main/scala/org/bitcoins/node/config/NodeAppConfig.scala +++ b/node/src/main/scala/org/bitcoins/node/config/NodeAppConfig.scala @@ -186,7 +186,7 @@ case class NodeAppConfig(baseDatadir: Path, configOverrides: Vector[Config])( if (config.hasPath("bitcoin-s.node.try-peers-interval")) { val duration = config.getDuration("bitcoin-s.node.try-peers-interval") TimeUtil.durationToFiniteDuration(duration) - } else 12.seconds + } else 1.hour } /** timeout to wait for response the messages extend [[org.bitcoins.core.p2p.ExpectsResponse]] */