Adjust period of time we query for peers on the p2p network from 12 seconds -> 1 hour (#4847)

This commit is contained in:
Chris Stewart 2022-10-17 14:42:14 -05:00 committed by GitHub
parent a4e38c30b4
commit f483e356cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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]] */