Skip to content

Commit 898c17b

Browse files
Remove ConnectionControlPlugin trait (#1797)
1 parent 55a629f commit 898c17b

File tree

4 files changed

+1
-26
lines changed

4 files changed

+1
-26
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala

-5
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ case class NodeParams(nodeKeyManager: NodeKeyManager,
9696

9797
val pluginMessageTags: Set[Int] = pluginParams.collect { case p: CustomFeaturePlugin => p.messageTags }.toSet.flatten
9898

99-
def forceReconnect(nodeId: PublicKey): Boolean = pluginParams.exists {
100-
case p: ConnectionControlPlugin => p.forceReconnect(nodeId)
101-
case _ => false
102-
}
103-
10499
def currentBlockHeight: Long = blockCount.get
105100

106101
def featuresFor(nodeId: PublicKey): Features = overrideFeatures.getOrElse(nodeId, features)

eclair-core/src/main/scala/fr/acinq/eclair/PluginParams.scala

-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ trait CustomFeaturePlugin extends PluginParams {
4040
def pluginFeature: UnknownFeature = UnknownFeature(feature.optional)
4141
}
4242

43-
trait ConnectionControlPlugin extends PluginParams {
44-
/** Once disconnect happens, should Eclair attempt periodic reconnects to a given remote node even if there is no normal channels left */
45-
def forceReconnect(nodeId: PublicKey): Boolean
46-
}
47-
4843
/** Parameters for a plugin that defines custom commitment transactions (or non-standard HTLCs). */
4944
trait CustomCommitmentsPlugin extends PluginParams {
5045
/**

eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends
8383

8484
when(IDLE) {
8585
case Event(Peer.Transition(previousPeerData, nextPeerData: Peer.DisconnectedData), d: IdleData) =>
86-
if (nodeParams.autoReconnect && (nodeParams.forceReconnect(remoteNodeId) || nextPeerData.channels.nonEmpty)) { // we only reconnect if nodeParams explicitly instructs us to or there are existing channels
86+
if (nodeParams.autoReconnect && nextPeerData.channels.nonEmpty) { // we only reconnect if nodeParams explicitly instructs us to or there are existing channels
8787
val (initialDelay, firstNextReconnectionDelay) = (previousPeerData, d.previousData) match {
8888
case (Peer.Nothing, _) =>
8989
// When restarting, we add some randomization before the first reconnection attempt to avoid herd effect

eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala

-15
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
4646
import com.softwaremill.quicklens._
4747
val aliceParams = TestConstants.Alice.nodeParams
4848
.modify(_.autoReconnect).setToIf(test.tags.contains("auto_reconnect"))(true)
49-
.modify(_.pluginParams).setToIf(test.tags.contains("plugin_force_reconnect"))(List(new ConnectionControlPlugin {
50-
// @formatter:off
51-
override def forceReconnect(nodeId: PublicKey): Boolean = true
52-
override def name = "plugin with force-reconnect"
53-
// @formatter:on
54-
}))
5549

5650
if (test.tags.contains("with_node_announcements")) {
5751
val bobAnnouncement = NodeAnnouncement(randomBytes64, Features.empty, 1, remoteNodeId, Color(100.toByte, 200.toByte, 300.toByte), "node-alias", fakeIPAddress :: Nil)
@@ -87,15 +81,6 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
8781
monitor.expectNoMessage()
8882
}
8983

90-
test("reconnect when there are no channels if plugin instructs to", Tag("auto_reconnect"), Tag("with_node_announcements"), Tag("plugin_force_reconnect")) { f =>
91-
import f._
92-
93-
val peer = TestProbe()
94-
peer.send(reconnectionTask, Peer.Transition(PeerNothingData, Peer.DisconnectedData(channels = Map.empty)))
95-
val TransitionWithData(ReconnectionTask.IDLE, ReconnectionTask.WAITING, _, _) = monitor.expectMsgType[TransitionWithData]
96-
val TransitionWithData(ReconnectionTask.WAITING, ReconnectionTask.CONNECTING, _, _: ReconnectionTask.ConnectingData) = monitor.expectMsgType[TransitionWithData]
97-
}
98-
9984
test("only try to connect once at startup if auto-reconnect is enabled but there are no known address", Tag("auto_reconnect")) { f =>
10085
import f._
10186

0 commit comments

Comments
 (0)