mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-20 02:11:40 +01:00
2023 06 28 connection fail logs (#5121)
* Rework logs for the case where our tcp connection fails. This makes the logs simpler * Revert initialDelay * Remove redundant setting
This commit is contained in:
parent
aa8da307b7
commit
f522ffec72
@ -124,7 +124,7 @@ case class PeerFinder(
|
||||
|
||||
private val _peersToTry: PeerStack = PeerStack()
|
||||
|
||||
val maxPeerSearchCount: Int = 1000
|
||||
private val maxPeerSearchCount: Int = 8
|
||||
|
||||
private val initialDelay: FiniteDuration = 30.minute
|
||||
|
||||
@ -138,10 +138,13 @@ case class PeerFinder(
|
||||
if (isConnectionSchedulerRunning.compareAndSet(false, true)) {
|
||||
logger.info(s"Querying p2p network for peers...")
|
||||
logger.debug(s"Cache size: ${_peerData.size}. ${_peerData.keys}")
|
||||
if (_peersToTry.size < 32)
|
||||
if (_peersToTry.size < maxPeerSearchCount)
|
||||
_peersToTry.pushAll(getPeersFromDnsSeeds)
|
||||
|
||||
val peers = (for { _ <- 1 to 32 } yield _peersToTry.pop()).distinct
|
||||
val peers = (
|
||||
1.to(maxPeerSearchCount)
|
||||
.map(_ => _peersToTry.pop()))
|
||||
.distinct
|
||||
.filterNot(p => skipPeers().contains(p) || _peerData.contains(p))
|
||||
|
||||
logger.debug(s"Trying next set of peers $peers")
|
||||
@ -151,7 +154,8 @@ case class PeerFinder(
|
||||
isConnectionSchedulerRunning.set(false)
|
||||
case Failure(err) =>
|
||||
isConnectionSchedulerRunning.set(false)
|
||||
logger.error(s"Failed to connect to peers=$peers", err)
|
||||
logger.error(
|
||||
s"Failed to connect to peers=$peers errMsg=${err.getMessage}")
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
|
@ -2,8 +2,8 @@ package org.bitcoins.node.networking.peer
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.actor.{ActorRef, ActorSystem, Cancellable}
|
||||
import akka.event.Logging
|
||||
import akka.io.Tcp.SO.KeepAlive
|
||||
import akka.stream.{KillSwitches, UniqueKillSwitch}
|
||||
import akka.stream.scaladsl.{
|
||||
BidiFlow,
|
||||
Flow,
|
||||
@ -14,6 +14,7 @@ import akka.stream.scaladsl.{
|
||||
Source,
|
||||
Tcp
|
||||
}
|
||||
import akka.stream.{Attributes, KillSwitches, UniqueKillSwitch}
|
||||
import akka.util.ByteString
|
||||
import org.bitcoins.chain.blockchain.ChainHandler
|
||||
import org.bitcoins.chain.config.ChainAppConfig
|
||||
@ -57,9 +58,7 @@ case class PeerMessageSender(
|
||||
ByteString,
|
||||
ByteString,
|
||||
Future[Tcp.OutgoingConnection]] = {
|
||||
Tcp(system).outgoingConnection(peer.socket,
|
||||
halfClose = false,
|
||||
options = options)
|
||||
Tcp(system).outgoingConnection(socket, halfClose = false, options = options)
|
||||
}
|
||||
|
||||
private def parseHelper(
|
||||
@ -99,6 +98,7 @@ case class PeerMessageSender(
|
||||
{ case msgs: Vector[NetworkMessage] =>
|
||||
s"received msgs=${msgs.map(_.payload.commandName)} from peer=$peer"
|
||||
})
|
||||
.withAttributes(Attributes.logLevels(onFailure = Logging.DebugLevel))
|
||||
}
|
||||
|
||||
private val writeNetworkMsgFlow: Flow[NetworkMessage, ByteString, NotUsed] = {
|
||||
@ -194,9 +194,13 @@ case class PeerMessageSender(
|
||||
buildConnectionGraph().run()
|
||||
}
|
||||
|
||||
outgoingConnectionF.map { o =>
|
||||
logger.info(
|
||||
s"Connected to remote=${o.remoteAddress} local=${o.localAddress}")
|
||||
outgoingConnectionF.onComplete {
|
||||
case scala.util.Success(o) =>
|
||||
logger.info(
|
||||
s"Connected to remote=${o.remoteAddress} local=${o.localAddress}")
|
||||
case scala.util.Failure(err) =>
|
||||
logger.info(
|
||||
s"Failed to connect to peer=$peer with errMsg=${err.getMessage}")
|
||||
}
|
||||
|
||||
val graph = ConnectionGraph(mergeHubSink = mergeHubSink,
|
||||
@ -216,9 +220,6 @@ case class PeerMessageSender(
|
||||
.flatMap { p =>
|
||||
p.disconnect(peer)
|
||||
}
|
||||
.failed
|
||||
.foreach(err =>
|
||||
logger.error(s"Failed disconnect callback with peer=$peer", err))
|
||||
|
||||
resultF.map(_ => ())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user