mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-12 10:30:45 +01:00
added support for 'initial_routing_sync' feature bit
This commit is contained in:
parent
6bd14bb089
commit
e2fc3fbecc
5 changed files with 23 additions and 13 deletions
|
@ -9,4 +9,6 @@ object Features {
|
||||||
|
|
||||||
def isChannelPublic(localFeatures: BinaryData): Boolean = localFeatures.size >= 1 && localFeatures.data(0) == 0x01
|
def isChannelPublic(localFeatures: BinaryData): Boolean = localFeatures.size >= 1 && localFeatures.data(0) == 0x01
|
||||||
|
|
||||||
|
def requiresInitialRoutingSync(localFeatures: BinaryData): Boolean = localFeatures.size >= 2 && localFeatures.data(1) == 0x01
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ object Globals {
|
||||||
}
|
}
|
||||||
|
|
||||||
val global_features = BinaryData("")
|
val global_features = BinaryData("")
|
||||||
val local_features = BinaryData("01") // public channel
|
val local_features = BinaryData("0101") // public channel
|
||||||
|
|
||||||
val expiry_delta_blocks = config.getInt("expiry-delta-blocks")
|
val expiry_delta_blocks = config.getInt("expiry-delta-blocks")
|
||||||
val htlc_minimum_msat = config.getInt("htlc-minimum-msat")
|
val htlc_minimum_msat = config.getInt("htlc-minimum-msat")
|
||||||
|
|
|
@ -9,7 +9,7 @@ import fr.acinq.eclair.blockchain.peer.CurrentBlockCount
|
||||||
import fr.acinq.eclair.channel.Helpers.{Closing, Funding}
|
import fr.acinq.eclair.channel.Helpers.{Closing, Funding}
|
||||||
import fr.acinq.eclair.crypto.{Generators, ShaChain}
|
import fr.acinq.eclair.crypto.{Generators, ShaChain}
|
||||||
import fr.acinq.eclair.payment.Binding
|
import fr.acinq.eclair.payment.Binding
|
||||||
import fr.acinq.eclair.router.Announcements
|
import fr.acinq.eclair.router.{Announcements, SendRoutingState}
|
||||||
import fr.acinq.eclair.transactions._
|
import fr.acinq.eclair.transactions._
|
||||||
import fr.acinq.eclair.wire._
|
import fr.acinq.eclair.wire._
|
||||||
|
|
||||||
|
@ -82,6 +82,9 @@ class Channel(val them: ActorRef, val blockchain: ActorRef, router: ActorRef, re
|
||||||
case Event(Init(remoteGlobalFeatures, remoteLocalFeatures), DATA_WAIT_FOR_INIT(localParams, Left(initFunder), autoSignInterval)) =>
|
case Event(Init(remoteGlobalFeatures, remoteLocalFeatures), DATA_WAIT_FOR_INIT(localParams, Left(initFunder), autoSignInterval)) =>
|
||||||
val temporaryChannelId = Platform.currentTime
|
val temporaryChannelId = Platform.currentTime
|
||||||
val firstPerCommitmentPoint = Generators.perCommitPoint(localParams.shaSeed, 0)
|
val firstPerCommitmentPoint = Generators.perCommitPoint(localParams.shaSeed, 0)
|
||||||
|
if (Features.requiresInitialRoutingSync(remoteLocalFeatures)) {
|
||||||
|
router ! SendRoutingState(them)
|
||||||
|
}
|
||||||
them ! OpenChannel(temporaryChannelId = temporaryChannelId,
|
them ! OpenChannel(temporaryChannelId = temporaryChannelId,
|
||||||
fundingSatoshis = initFunder.fundingSatoshis,
|
fundingSatoshis = initFunder.fundingSatoshis,
|
||||||
pushMsat = initFunder.pushMsat,
|
pushMsat = initFunder.pushMsat,
|
||||||
|
@ -100,6 +103,9 @@ class Channel(val them: ActorRef, val blockchain: ActorRef, router: ActorRef, re
|
||||||
goto(WAIT_FOR_ACCEPT_CHANNEL) using DATA_WAIT_FOR_ACCEPT_CHANNEL(temporaryChannelId, localParams, fundingSatoshis = initFunder.fundingSatoshis, pushMsat = initFunder.pushMsat, remoteGlobalFeatures = remoteGlobalFeatures, remoteLocalFeatures = remoteLocalFeatures, autoSignInterval = autoSignInterval)
|
goto(WAIT_FOR_ACCEPT_CHANNEL) using DATA_WAIT_FOR_ACCEPT_CHANNEL(temporaryChannelId, localParams, fundingSatoshis = initFunder.fundingSatoshis, pushMsat = initFunder.pushMsat, remoteGlobalFeatures = remoteGlobalFeatures, remoteLocalFeatures = remoteLocalFeatures, autoSignInterval = autoSignInterval)
|
||||||
|
|
||||||
case Event(Init(remoteGlobalFeatures, remoteLocalFeatures), DATA_WAIT_FOR_INIT(localParams, Right(initFundee), autoSignInterval)) =>
|
case Event(Init(remoteGlobalFeatures, remoteLocalFeatures), DATA_WAIT_FOR_INIT(localParams, Right(initFundee), autoSignInterval)) =>
|
||||||
|
if (Features.requiresInitialRoutingSync(remoteLocalFeatures)) {
|
||||||
|
router ! SendRoutingState(them)
|
||||||
|
}
|
||||||
goto(WAIT_FOR_OPEN_CHANNEL) using DATA_WAIT_FOR_OPEN_CHANNEL(localParams, remoteGlobalFeatures = remoteGlobalFeatures, remoteLocalFeatures = remoteLocalFeatures, autoSignInterval = autoSignInterval)
|
goto(WAIT_FOR_OPEN_CHANNEL) using DATA_WAIT_FOR_OPEN_CHANNEL(localParams, remoteGlobalFeatures = remoteGlobalFeatures, remoteLocalFeatures = remoteLocalFeatures, autoSignInterval = autoSignInterval)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ case class ChannelDesc(id: Long, a: BinaryData, b: BinaryData)
|
||||||
case class Hop(nodeId: BinaryData, nextNodeId: BinaryData, lastUpdate: ChannelUpdate)
|
case class Hop(nodeId: BinaryData, nextNodeId: BinaryData, lastUpdate: ChannelUpdate)
|
||||||
case class RouteRequest(source: BinaryData, target: BinaryData)
|
case class RouteRequest(source: BinaryData, target: BinaryData)
|
||||||
case class RouteResponse(hops: Seq[Hop]) { require(hops.size > 0, "route cannot be empty") }
|
case class RouteResponse(hops: Seq[Hop]) { require(hops.size > 0, "route cannot be empty") }
|
||||||
|
case class SendRoutingState(to: ActorRef)
|
||||||
|
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
|
@ -38,8 +39,6 @@ class Router(watcher: ActorRef) extends Actor with ActorLogging {
|
||||||
import Router._
|
import Router._
|
||||||
|
|
||||||
import ExecutionContext.Implicits.global
|
import ExecutionContext.Implicits.global
|
||||||
|
|
||||||
context.system.eventStream.subscribe(self, classOf[ChannelChangedState])
|
|
||||||
context.system.scheduler.schedule(10 seconds, 60 seconds, self, 'tick_broadcast)
|
context.system.scheduler.schedule(10 seconds, 60 seconds, self, 'tick_broadcast)
|
||||||
|
|
||||||
def receive: Receive = main(nodes = Map(), channels = Map(), updates = Map(), rebroadcast = Nil, awaiting = Set(), stash = Nil)
|
def receive: Receive = main(nodes = Map(), channels = Map(), updates = Map(), rebroadcast = Nil, awaiting = Set(), stash = Nil)
|
||||||
|
@ -62,15 +61,11 @@ class Router(watcher: ActorRef) extends Actor with ActorLogging {
|
||||||
awaiting: Set[ChannelAnnouncement],
|
awaiting: Set[ChannelAnnouncement],
|
||||||
stash: Seq[RoutingMessage]): Receive = {
|
stash: Seq[RoutingMessage]): Receive = {
|
||||||
|
|
||||||
case ChannelChangedState(channel, transport, _, WAIT_FOR_INIT_INTERNAL, _, _) =>
|
case SendRoutingState(remote) =>
|
||||||
// we send all known announcements to the new peer as soon as the connection is opened
|
log.info(s"info sending all announcements to $remote: channels=${channels.size} nodes=${nodes.size} updates=${updates.size}")
|
||||||
log.info(s"info sending all announcements to $channel: channels=${channels.size} nodes=${nodes.size} updates=${updates.size}")
|
channels.values.foreach(remote ! _)
|
||||||
channels.values.foreach(transport ! _)
|
updates.values.foreach(remote ! _)
|
||||||
nodes.values.foreach(transport ! _)
|
nodes.values.foreach(remote ! _)
|
||||||
updates.values.foreach(transport ! _)
|
|
||||||
|
|
||||||
case s: ChannelChangedState =>
|
|
||||||
// other channel changed state messages are ignored
|
|
||||||
|
|
||||||
case c: ChannelAnnouncement if !Announcements.checkSigs(c) =>
|
case c: ChannelAnnouncement if !Announcements.checkSigs(c) =>
|
||||||
// TODO: (dirty) this will make the origin channel close the connection
|
// TODO: (dirty) this will make the origin channel close the connection
|
||||||
|
|
|
@ -17,4 +17,11 @@ class FeaturesSpec extends FunSuite {
|
||||||
assert(isChannelPublic("01") === true)
|
assert(isChannelPublic("01") === true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("'initial_routing_sync' feature") {
|
||||||
|
assert(requiresInitialRoutingSync("") === false)
|
||||||
|
assert(requiresInitialRoutingSync("01") === false)
|
||||||
|
assert(requiresInitialRoutingSync("0000") === false)
|
||||||
|
assert(requiresInitialRoutingSync("0001") === true)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue