Skip to content

Commit

Permalink
pay: Change var name total_amount to capacity
Browse files Browse the repository at this point in the history
Suggested-by: Rusty Russell <@rustyrussell>
  • Loading branch information
cdecker committed Aug 9, 2024
1 parent 093fb76 commit dc74fd8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion common/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ static bool dijkstra_to_hops(struct route_hop **hops,
return false;

gossmap_chan_get_capacity(gossmap, c, &total);
(*hops)[num_hops].total_amount.millisatoshis = total.satoshis * 1000; /* Raw: simpler. */

if (!amount_sat_to_msat(&(*hops)[num_hops].capacity, total))
abort();

(*hops)[num_hops].amount = *amount;
(*hops)[num_hops].delay = *cltv;

Expand Down
2 changes: 1 addition & 1 deletion common/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct route_hop {
int direction;
struct node_id node_id;
struct amount_msat amount;
struct amount_msat total_amount;
struct amount_msat capacity;
u32 delay;
};

Expand Down
12 changes: 6 additions & 6 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static void payment_exclude_most_expensive(struct payment *p)
}
}
channel_hints_update(p, e->scid, e->direction, false, false, NULL,
e->total_amount, NULL);
e->capacity, NULL);
}

static void payment_exclude_longest_delay(struct payment *p)
Expand All @@ -521,7 +521,7 @@ static void payment_exclude_longest_delay(struct payment *p)
}
}
channel_hints_update(p, e->scid, e->direction, false, false, NULL,
e->total_amount, NULL);
e->capacity, NULL);
}

static struct amount_msat payment_route_fee(struct payment *p)
Expand Down Expand Up @@ -1536,7 +1536,7 @@ handle_intermediate_failure(struct command *cmd,
case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:
/* All of these result in the channel being marked as disabled. */
channel_hints_update(root, errchan->scid, errchan->direction,
false, false, NULL, errchan->total_amount,
false, false, NULL, errchan->capacity,
NULL);
break;

Expand All @@ -1555,7 +1555,7 @@ handle_intermediate_failure(struct command *cmd,
* remember the amount we tried as an estimate. */
channel_hints_update(root, errchan->scid, errchan->direction,
true, false, &estimated,
errchan->total_amount, NULL);
errchan->capacity, NULL);
goto error;
}

Expand Down Expand Up @@ -3173,7 +3173,7 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
hop.amount = dest_amount;
hop.delay = route_cltv(d->final_cltv, routehint + i + 1,
tal_count(routehint) - i - 1);
hop.total_amount = estimate;
hop.capacity = estimate;

/* Should we get a failure inside the routehint we'll
* need the direction so we can exclude it. Luckily
Expand Down Expand Up @@ -3542,7 +3542,7 @@ static void direct_pay_override(struct payment *p) {
p->route[0].scid = hint->scid.scid;
p->route[0].direction = hint->scid.dir;
p->route[0].node_id = *p->route_destination;
p->route[0].total_amount = hint->overall_capacity;
p->route[0].capacity = hint->overall_capacity;
paymod_log(p, LOG_DBG,
"Found a direct channel (%s) with sufficient "
"capacity, skipping route computation.",
Expand Down

0 comments on commit dc74fd8

Please sign in to comment.