1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-24 14:50:46 +01:00

Remove ConnectionControlPlugin trait (#1797)

This commit is contained in:
Anton Kumaigorodski 2021-05-14 10:17:11 +03:00 committed by GitHub
parent 55a629f11d
commit 898c17bc76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 1 additions and 26 deletions

View file

@ -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)

View file

@ -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 {
/**

View file

@ -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

View file

@ -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)
@ -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._