Skip to content

Commit

Permalink
Do not estimate balance for local channels (#2988)
Browse files Browse the repository at this point in the history
We already know th balance of local channels, we don't need to estimate it.
  • Loading branch information
thomash-acinq authored Jan 29, 2025
1 parent 5a1811b commit 73ea751
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,17 @@ case class GraphWithBalanceEstimates(graph: DirectedGraph, private val balances:
}

def routeCouldRelay(route: Route)(implicit log: LoggingAdapter): GraphWithBalanceEstimates = {
val (balances1, _) = route.hops.foldRight((balances, route.amount)) {
// We drop the first hop which is a local channel, we already have perfect balance information for local channels.
val (balances1, _) = route.hops.drop(1).foldRight((balances, route.amount)) {
case (hop, (balances, amount)) =>
(balances.channelCouldSend(hop, amount), amount + hop.fee(amount))
}
GraphWithBalanceEstimates(graph, balances1)
}

def routeDidRelay(route: Route)(implicit log: LoggingAdapter): GraphWithBalanceEstimates = {
val (balances1, _) = route.hops.foldRight((balances, route.amount)) {
// We drop the first hop which is a local channel, we already have perfect balance information for local channels.
val (balances1, _) = route.hops.drop(1).foldRight((balances, route.amount)) {
case (hop, (balances, amount)) =>
(balances.channelDidSend(hop, amount), amount + hop.fee(amount))
}
Expand Down

0 comments on commit 73ea751

Please sign in to comment.