1
0
Fork 0
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:
pm47 2020-09-30 15:32:09 +02:00
parent 9587a4e012
commit d0b405fa62
No known key found for this signature in database
GPG key ID: E434ED292E85643A
3 changed files with 15 additions and 14 deletions

View file

@ -80,7 +80,7 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends
when(IDLE) {
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 {
case (Peer.Nothing, _) =>
// 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(Peer.Connect(_, hostAndPort_opt), _) =>
// manual connection requests happen completely independently of the automated reconnection process;
// we initiate a connection but don't modify our state.
// if we are already connecting/connected, the peer will kill any duplicate connections
hostAndPort_opt
.map(hostAndPort2InetSocketAddress)
.orElse(getPeerAddressFromDb(nodeParams.db.peers, nodeParams.db.network, remoteNodeId)) match {
case Some(address) => connect(address, origin = sender)
case None => sender ! PeerConnection.ConnectionResult.NoAddressFound
}
// On Phoenix we ignore manual reconnection attempts, everything is always handled by the auto-reconnection loop
// // manual connection requests happen completely independently of the automated reconnection process;
// // we initiate a connection but don't modify our state.
// // if we are already connecting/connected, the peer will kill any duplicate connections
// hostAndPort_opt
// .map(hostAndPort2InetSocketAddress)
// .orElse(getPeerAddressFromDb(nodeParams.db.peers, nodeParams.db.network, remoteNodeId)) match {
// case Some(address) => connect(address, origin = sender)
// case None => sender ! PeerConnection.ConnectionResult.NoAddressFound
// }
stay
}

View file

@ -90,7 +90,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe
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._
val probe = TestProbe()
@ -99,7 +99,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe
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._
// this actor listens to connection requests and creates connections

View file

@ -77,7 +77,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
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._
val peer = TestProbe()
@ -158,7 +158,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
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._
// we create a dummy tcp server and update bob's announcement to point to it