Skip to content

Commit

Permalink
Remove ConnectionControlPlugin trait (#1797)
Browse files Browse the repository at this point in the history
  • Loading branch information
akumaigorodski authored May 14, 2021
1 parent 55a629f commit 898c17b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 26 deletions.
5 changes: 0 additions & 5 deletions eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ case class NodeParams(nodeKeyManager: NodeKeyManager,

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

def forceReconnect(nodeId: PublicKey): Boolean = pluginParams.exists {
case p: ConnectionControlPlugin => p.forceReconnect(nodeId)
case _ => false
}

def currentBlockHeight: Long = blockCount.get

def featuresFor(nodeId: PublicKey): Features = overrideFeatures.getOrElse(nodeId, features)
Expand Down
5 changes: 0 additions & 5 deletions eclair-core/src/main/scala/fr/acinq/eclair/PluginParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ trait CustomFeaturePlugin extends PluginParams {
def pluginFeature: UnknownFeature = UnknownFeature(feature.optional)
}

trait ConnectionControlPlugin extends PluginParams {
/** Once disconnect happens, should Eclair attempt periodic reconnects to a given remote node even if there is no normal channels left */
def forceReconnect(nodeId: PublicKey): Boolean
}

/** Parameters for a plugin that defines custom commitment transactions (or non-standard HTLCs). */
trait CustomCommitmentsPlugin extends PluginParams {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends

when(IDLE) {
case Event(Peer.Transition(previousPeerData, nextPeerData: Peer.DisconnectedData), d: IdleData) =>
if (nodeParams.autoReconnect && (nodeParams.forceReconnect(remoteNodeId) || nextPeerData.channels.nonEmpty)) { // we only reconnect if nodeParams explicitly instructs us to or there are existing channels
if (nodeParams.autoReconnect && nextPeerData.channels.nonEmpty) { // we only reconnect if nodeParams explicitly instructs us to or there are existing channels
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
import com.softwaremill.quicklens._
val aliceParams = TestConstants.Alice.nodeParams
.modify(_.autoReconnect).setToIf(test.tags.contains("auto_reconnect"))(true)
.modify(_.pluginParams).setToIf(test.tags.contains("plugin_force_reconnect"))(List(new ConnectionControlPlugin {
// @formatter:off
override def forceReconnect(nodeId: PublicKey): Boolean = true
override def name = "plugin with force-reconnect"
// @formatter:on
}))

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

test("reconnect when there are no channels if plugin instructs to", Tag("auto_reconnect"), Tag("with_node_announcements"), Tag("plugin_force_reconnect")) { f =>
import f._

val peer = TestProbe()
peer.send(reconnectionTask, Peer.Transition(PeerNothingData, Peer.DisconnectedData(channels = Map.empty)))
val TransitionWithData(ReconnectionTask.IDLE, ReconnectionTask.WAITING, _, _) = monitor.expectMsgType[TransitionWithData]
val TransitionWithData(ReconnectionTask.WAITING, ReconnectionTask.CONNECTING, _, _: ReconnectionTask.ConnectingData) = monitor.expectMsgType[TransitionWithData]
}

test("only try to connect once at startup if auto-reconnect is enabled but there are no known address", Tag("auto_reconnect")) { f =>
import f._

Expand Down

0 comments on commit 898c17b

Please sign in to comment.