mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-13 19:37:35 +01:00
special connection handling on phoenix
We always automatically reconnect, whether or not there are existing channels. Manual connection requests are ignored.
This commit is contained in:
parent
9587a4e012
commit
d0b405fa62
3 changed files with 15 additions and 14 deletions
|
@ -80,7 +80,7 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends
|
||||||
|
|
||||||
when(IDLE) {
|
when(IDLE) {
|
||||||
case Event(Peer.Transition(previousPeerData, nextPeerData: Peer.DisconnectedData), d: IdleData) =>
|
case Event(Peer.Transition(previousPeerData, nextPeerData: Peer.DisconnectedData), d: IdleData) =>
|
||||||
if (nodeParams.autoReconnect && nextPeerData.channels.nonEmpty) { // we only reconnect if there are existing channels
|
if (nodeParams.autoReconnect /*&& nextPeerData.channels.nonEmpty*/) { // On Phoenix we always reconnect
|
||||||
val (initialDelay, firstNextReconnectionDelay) = (previousPeerData, d.previousData) match {
|
val (initialDelay, firstNextReconnectionDelay) = (previousPeerData, d.previousData) match {
|
||||||
case (Peer.Nothing, _) =>
|
case (Peer.Nothing, _) =>
|
||||||
// When restarting, we add some randomization before the first reconnection attempt to avoid herd effect
|
// When restarting, we add some randomization before the first reconnection attempt to avoid herd effect
|
||||||
|
@ -126,15 +126,16 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends
|
||||||
case Event(TickReconnect, _) => stay
|
case Event(TickReconnect, _) => stay
|
||||||
|
|
||||||
case Event(Peer.Connect(_, hostAndPort_opt), _) =>
|
case Event(Peer.Connect(_, hostAndPort_opt), _) =>
|
||||||
// manual connection requests happen completely independently of the automated reconnection process;
|
// On Phoenix we ignore manual reconnection attempts, everything is always handled by the auto-reconnection loop
|
||||||
// we initiate a connection but don't modify our state.
|
// // manual connection requests happen completely independently of the automated reconnection process;
|
||||||
// if we are already connecting/connected, the peer will kill any duplicate connections
|
// // we initiate a connection but don't modify our state.
|
||||||
hostAndPort_opt
|
// // if we are already connecting/connected, the peer will kill any duplicate connections
|
||||||
.map(hostAndPort2InetSocketAddress)
|
// hostAndPort_opt
|
||||||
.orElse(getPeerAddressFromDb(nodeParams.db.peers, nodeParams.db.network, remoteNodeId)) match {
|
// .map(hostAndPort2InetSocketAddress)
|
||||||
case Some(address) => connect(address, origin = sender)
|
// .orElse(getPeerAddressFromDb(nodeParams.db.peers, nodeParams.db.network, remoteNodeId)) match {
|
||||||
case None => sender ! PeerConnection.ConnectionResult.NoAddressFound
|
// case Some(address) => connect(address, origin = sender)
|
||||||
}
|
// case None => sender ! PeerConnection.ConnectionResult.NoAddressFound
|
||||||
|
// }
|
||||||
stay
|
stay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe
|
||||||
probe.expectMsg(PeerInfo(remoteNodeId, "CONNECTED", Some(fakeIPAddress.socketAddress), 1))
|
probe.expectMsg(PeerInfo(remoteNodeId, "CONNECTED", Some(fakeIPAddress.socketAddress), 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
test("fail to connect if no address provided or found") { f =>
|
ignore("fail to connect if no address provided or found") { f =>
|
||||||
import f._
|
import f._
|
||||||
|
|
||||||
val probe = TestProbe()
|
val probe = TestProbe()
|
||||||
|
@ -99,7 +99,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe
|
||||||
probe.expectMsg(PeerConnection.ConnectionResult.NoAddressFound)
|
probe.expectMsg(PeerConnection.ConnectionResult.NoAddressFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
test("successfully connect to peer at user request") { f =>
|
ignore("successfully connect to peer at user request") { f =>
|
||||||
import f._
|
import f._
|
||||||
|
|
||||||
// this actor listens to connection requests and creates connections
|
// this actor listens to connection requests and creates connections
|
||||||
|
|
|
@ -77,7 +77,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
|
||||||
monitor.expectNoMsg()
|
monitor.expectNoMsg()
|
||||||
}
|
}
|
||||||
|
|
||||||
test("stay idle at startup if there are no channels", Tag("auto_reconnect"), Tag("with_node_announcements")) { f =>
|
ignore("stay idle at startup if there are no channels", Tag("auto_reconnect"), Tag("with_node_announcements")) { f =>
|
||||||
import f._
|
import f._
|
||||||
|
|
||||||
val peer = TestProbe()
|
val peer = TestProbe()
|
||||||
|
@ -158,7 +158,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
|
||||||
assert(waitingData3.nextReconnectionDelay === (waitingData0.nextReconnectionDelay * 8))
|
assert(waitingData3.nextReconnectionDelay === (waitingData0.nextReconnectionDelay * 8))
|
||||||
}
|
}
|
||||||
|
|
||||||
test("reconnect using the address from node_announcement") { f =>
|
ignore("reconnect using the address from node_announcement") { f =>
|
||||||
import f._
|
import f._
|
||||||
|
|
||||||
// we create a dummy tcp server and update bob's announcement to point to it
|
// we create a dummy tcp server and update bob's announcement to point to it
|
||||||
|
|
Loading…
Add table
Reference in a new issue