Skip to content

Commit

Permalink
use multiple channels in parallel [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
pm47 committed May 17, 2021
1 parent 2ee43ad commit 894c603
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import fr.acinq.eclair.wire.protocol.ChannelUpdate
import scala.annotation.tailrec
import scala.collection.immutable.SortedMap
import scala.collection.mutable
import scala.util.Random

object Graph {

Expand Down Expand Up @@ -229,7 +230,8 @@ object Graph {
if (canRelayAmount && boundaries(neighborWeight) && !ignoredEdges.contains(edge.desc) && !ignoredVertices.contains(neighbor)) {
val previousNeighborWeight = bestWeights.getOrElse(neighbor, RichWeight(MilliSatoshi(Long.MaxValue), Int.MaxValue, CltvExpiryDelta(Int.MaxValue), Double.MaxValue))
// if this path between neighbor and the target has a shorter distance than previously known, we select it
if (neighborWeight.weight < previousNeighborWeight.weight) {
if (neighborWeight.weight < previousNeighborWeight.weight ||
(neighborWeight.weight == previousNeighborWeight.weight && Random.nextInt(1) == 0)) {
// update the best edge for this vertex
bestEdges.put(neighbor, edge)
// add this updated node to the list for further exploration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,22 @@ class PerformanceIntegrationSpec extends IntegrationSpec {
val eventListener = TestProbe()
nodes.values.foreach(_.system.eventStream.subscribe(eventListener.ref, classOf[ChannelStateChanged]))

connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat)

// confirming the funding tx
generateBlocks(6)

within(60 seconds) {
eventListener.expectMsgType[ChannelStateChanged](60 seconds).currentState == NORMAL
eventListener.expectMsgType[ChannelStateChanged](60 seconds).currentState == NORMAL
eventListener.expectMsgType[ChannelStateChanged](60 seconds).currentState == NORMAL
}
}

Expand All @@ -67,7 +76,7 @@ class PerformanceIntegrationSpec extends IntegrationSpec {
awaitCond({
sender.send(nodes("A").router, Router.GetRoutingState)
val routingState = sender.expectMsgType[Router.RoutingState]
routingState.channels.nonEmpty
routingState.channels.size == 8
}, 60 seconds)
}

Expand Down

0 comments on commit 894c603

Please sign in to comment.