mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-24 22:58:23 +01:00
Remove ConnectionControlPlugin trait (#1797)
This commit is contained in:
parent
55a629f11d
commit
898c17bc76
4 changed files with 1 additions and 26 deletions
|
@ -96,11 +96,6 @@ case class NodeParams(nodeKeyManager: NodeKeyManager,
|
||||||
|
|
||||||
val pluginMessageTags: Set[Int] = pluginParams.collect { case p: CustomFeaturePlugin => p.messageTags }.toSet.flatten
|
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 currentBlockHeight: Long = blockCount.get
|
||||||
|
|
||||||
def featuresFor(nodeId: PublicKey): Features = overrideFeatures.getOrElse(nodeId, features)
|
def featuresFor(nodeId: PublicKey): Features = overrideFeatures.getOrElse(nodeId, features)
|
||||||
|
|
|
@ -40,11 +40,6 @@ trait CustomFeaturePlugin extends PluginParams {
|
||||||
def pluginFeature: UnknownFeature = UnknownFeature(feature.optional)
|
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). */
|
/** Parameters for a plugin that defines custom commitment transactions (or non-standard HTLCs). */
|
||||||
trait CustomCommitmentsPlugin extends PluginParams {
|
trait CustomCommitmentsPlugin extends PluginParams {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -83,7 +83,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 && (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 {
|
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
|
||||||
|
|
|
@ -46,12 +46,6 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike
|
||||||
import com.softwaremill.quicklens._
|
import com.softwaremill.quicklens._
|
||||||
val aliceParams = TestConstants.Alice.nodeParams
|
val aliceParams = TestConstants.Alice.nodeParams
|
||||||
.modify(_.autoReconnect).setToIf(test.tags.contains("auto_reconnect"))(true)
|
.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")) {
|
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)
|
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()
|
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 =>
|
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._
|
import f._
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue