Fix bug where we were only setting bitcoin-s.node.inactivity-timeout on regtest (#5389)

* Fix bug where we were only setting bitcoin-s.node.inactivity-timeout on regtest

* Remove log, scalafmt
This commit is contained in:
Chris Stewart 2024-02-08 21:36:15 -06:00 committed by GitHub
parent 5544a2efc4
commit cac546bb57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 9 deletions

View file

@ -79,6 +79,7 @@ class ReConnectionTest extends NodeTestWithCachedBitcoindNewest {
//wait until there is a timeout for inactivity
_ <- NodeTestUtil.awaitConnectionCount(started, 1)
_ <- started.peerManager.isConnected(bitcoindPeer)
_ <- started.stop()
_ <- started.nodeConfig.stop()
} yield {

View file

@ -20,7 +20,6 @@ import org.bitcoins.chain.config.ChainAppConfig
import org.bitcoins.core.api.chain.ChainQueryApi.FilterResponse
import NodeState.DoneSyncing
import org.bitcoins.core.api.node.{NodeType, Peer}
import org.bitcoins.core.config.{MainNet, RegTest, SigNet, TestNet3}
import org.bitcoins.core.protocol.BlockStamp
import org.bitcoins.node.config.NodeAppConfig
@ -201,7 +200,7 @@ case class NeutrinoNode(
private def inactivityChecksRunnable(): Runnable = { () =>
val peers = peerManager.peers
logger.debug(s"Running inactivity checks for peers=${peers}")
logger.info(s"Running inactivity checks for peers=${peers}")
val resultF = if (peers.nonEmpty) {
Future.unit //do nothing?
} else if (isStarted.get) {
@ -220,11 +219,7 @@ case class NeutrinoNode(
}
private def startInactivityChecksJob(): Cancellable = {
//the interval is set shorter for some unit test cases
val interval = nodeAppConfig.network match {
case MainNet | TestNet3 | SigNet => 5.minute
case RegTest => nodeAppConfig.inactivityTimeout
}
val interval = nodeAppConfig.inactivityTimeout
system.scheduler.scheduleAtFixedRate(
initialDelay = interval,
interval = interval)(inactivityChecksRunnable())

View file

@ -378,9 +378,9 @@ case class PeerManager(
if (forceReconnect && !isShuttingDown) {
finder.reconnect(peer).map(_ => state)
} else {
val exn = new RuntimeException(
logger.warn(
s"No new peers to sync from, cannot start new sync. Terminated sync with peer=$peer current syncPeer=$syncPeerOpt state=${state} peers=$peers")
Future.failed(exn)
Future.successful(state)
}
} else {
if (forceReconnect && !isShuttingDown) {