mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Reset PeerConnection.connectionGraphOpt = None
when connection is disconnected (#5290)
* Reset PeerConnection.connectionGraphOpt = None when connection is disconnected * Move resetting connectionGraphOpt into PeerConnection.disconnect() * Call PeerData.stop() inside of PeerManager.onDisconnect() * Empty commit to run CI * Empty commit to re-run CI
This commit is contained in:
parent
c1baad9f06
commit
7b8df425fb
@ -347,9 +347,10 @@ class NeutrinoNodeTest extends NodeTestWithCachedBitcoindPair {
|
||||
_ <- AsyncUtil.nonBlockingSleep(1.second)
|
||||
initConnectionCount <- node.getConnectionCount
|
||||
_ = assert(initConnectionCount == 2)
|
||||
nodeUri0 <- NodeTestUtil.getNodeURIFromBitcoind(bitcoinds(0))
|
||||
peer0 <- NodeTestUtil.getBitcoindPeer(bitcoinds(0))
|
||||
_ <- bitcoinds(0).disconnectNode(nodeUri0)
|
||||
bitcoind0 = bitcoinds(0)
|
||||
nodeUri0 <- NodeTestUtil.getNodeURIFromBitcoind(bitcoind0)
|
||||
peer0 <- NodeTestUtil.getBitcoindPeer(bitcoind0)
|
||||
_ <- bitcoind0.disconnectNode(nodeUri0)
|
||||
_ <- AsyncUtil.retryUntilSatisfiedF(
|
||||
() => node.peerManager.isDisconnected(peer0),
|
||||
1.second)
|
||||
|
@ -449,9 +449,9 @@ case class PeerManager(
|
||||
//client actor for one of the test peers stopped, can remove it from map now
|
||||
finder.removePeer(peer).map(_ => state)
|
||||
} else if (peerDataMap.contains(peer)) {
|
||||
//actor stopped for one of the persistent peers, can happen in case a reconnection attempt failed due to
|
||||
//reconnection tries exceeding the max limit in which the client was stopped to disconnect from it, remove it
|
||||
val peerData = _peerDataMap(peer)
|
||||
_peerDataMap.remove(peer)
|
||||
peerData.stop().flatMap { _ =>
|
||||
//getDataMesageHandler.state is already mutated from another thread
|
||||
//this will be set to the new sync peer not the old one.
|
||||
val syncPeerOpt = state match {
|
||||
@ -464,8 +464,8 @@ case class PeerManager(
|
||||
val shouldReconnect =
|
||||
(forceReconnect || connectedPeerCount == 0) && isStarted.get
|
||||
if (peers.exists(_ != peer)) {
|
||||
val randomPeerOpt = randomPeerWithService(
|
||||
ServiceIdentifier.NODE_COMPACT_FILTERS)
|
||||
val randomPeerOpt =
|
||||
randomPeerWithService(ServiceIdentifier.NODE_COMPACT_FILTERS)
|
||||
randomPeerOpt match {
|
||||
case Some(peer) =>
|
||||
state match {
|
||||
@ -496,6 +496,7 @@ case class PeerManager(
|
||||
Future.successful(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (state.waitingForDisconnection.contains(peer)) {
|
||||
//a peer we wanted to disconnect has remove has stopped the client actor, finally mark this as deleted
|
||||
val removed = state.waitingForDisconnection.removedAll(Set(peer))
|
||||
|
@ -324,6 +324,7 @@ case class PeerConnection(peer: Peer, peerManager: PeerManager)(implicit
|
||||
case Some(cg) =>
|
||||
logger.info(s"Disconnecting peer=${peer}")
|
||||
cg.stop()
|
||||
connectionGraphOpt = None
|
||||
Future.unit
|
||||
case None =>
|
||||
val err =
|
||||
|
Loading…
Reference in New Issue
Block a user