mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
pay: Rename overall_capacity to just capacity
Suggested-by: Rusty Russell <@rustyrussell>
This commit is contained in:
parent
37a204df41
commit
cf09314b3b
3 changed files with 15 additions and 12 deletions
|
@ -9,8 +9,8 @@ void channel_hint_to_json(const char *name, const struct channel_hint *hint,
|
|||
json_add_short_channel_id_dir(dest, "scid", hint->scid);
|
||||
json_add_amount_msat(dest, "estimated_capacity_msat",
|
||||
hint->estimated_capacity);
|
||||
json_add_amount_msat(dest, "overall_capacity_msat",
|
||||
hint->overall_capacity);
|
||||
json_add_amount_msat(dest, "capacity_msat",
|
||||
hint->capacity);
|
||||
json_add_bool(dest, "enabled", hint->enabled);
|
||||
json_object_end(dest);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ bool channel_hint_update(const struct timeabs now, struct channel_hint *hint)
|
|||
*/
|
||||
struct amount_msat refill;
|
||||
u64 seconds = now.ts.tv_sec - hint->timestamp;
|
||||
if (!amount_msat_mul(&refill, hint->overall_capacity, seconds))
|
||||
if (!amount_msat_mul(&refill, hint->capacity, seconds))
|
||||
abort();
|
||||
|
||||
refill = amount_msat_div(refill, PAY_REFILL_TIME);
|
||||
|
@ -48,8 +48,8 @@ bool channel_hint_update(const struct timeabs now, struct channel_hint *hint)
|
|||
|
||||
/* Clamp the value to the `overall_capacity` */
|
||||
if (amount_msat_greater(hint->estimated_capacity,
|
||||
hint->overall_capacity))
|
||||
hint->estimated_capacity = hint->overall_capacity;
|
||||
hint->capacity))
|
||||
hint->estimated_capacity = hint->capacity;
|
||||
|
||||
/* TODO This is rather coarse. We could map the disabled flag
|
||||
to having 0msat capacity, and then relax from there. But it'd
|
||||
|
@ -65,7 +65,7 @@ bool channel_hint_update(const struct timeabs now, struct channel_hint *hint)
|
|||
/* We report this hint as useless, if the hint does not
|
||||
* restrict the channel, i.e., if it is enabled and the
|
||||
* estimate is the same as the overall capacity. */
|
||||
return !hint->enabled || amount_msat_greater(hint->overall_capacity,
|
||||
return !hint->enabled || amount_msat_greater(hint->capacity,
|
||||
hint->estimated_capacity);
|
||||
}
|
||||
|
||||
|
@ -85,11 +85,13 @@ struct channel_hint *channel_hint_from_json(const tal_t *ctx,
|
|||
*jhint =
|
||||
json_get_member(buffer, payload, "channel_hint");
|
||||
struct channel_hint *hint = tal(ctx, struct channel_hint);
|
||||
ret = json_scan(ctx, buffer, toks,
|
||||
"{timestamp:%,scid:%,estimated_capacity_msat:%,overall_capacity_msat:%,enabled:%}",
|
||||
|
||||
ret = json_scan(ctx, buffer, jhint,
|
||||
"{timestamp:%,scid:%,estimated_capacity_msat:%,capacity_sat:%,enabled:%}",
|
||||
JSON_SCAN(json_to_u32, &hint->timestamp),
|
||||
JSON_SCAN(json_to_short_channel_id_dir, &hint->scid),
|
||||
JSON_SCAN(json_to_msat, &hint->estimated_capacity),
|
||||
JSON_SCAN(json_to_msat, &hint->capacity),
|
||||
JSON_SCAN(json_to_bool, &hint->enabled));
|
||||
|
||||
if (ret != NULL)
|
||||
|
|
|
@ -43,7 +43,7 @@ struct channel_hint {
|
|||
/* The total `amount_msat` that were used to fund the
|
||||
* channel. This is always smaller gte the
|
||||
* estimated_capacity */
|
||||
struct amount_msat overall_capacity;
|
||||
struct amount_msat capacity;
|
||||
};
|
||||
|
||||
/* A collection of channel_hint instances, allowing us to handle and
|
||||
|
@ -56,6 +56,7 @@ struct channel_hint_set {
|
|||
bool channel_hint_update(const struct timeabs now,
|
||||
struct channel_hint *hint);
|
||||
|
||||
void channel_hint_to_json(const char *name, const struct channel_hint *hint, struct json_stream *dest);
|
||||
void channel_hint_to_json(const char *name, const struct channel_hint *hint,
|
||||
struct json_stream *dest);
|
||||
|
||||
#endif /* LIGHTNING_PLUGINS_CHANNEL_HINT_H */
|
||||
|
|
|
@ -467,7 +467,7 @@ static void channel_hints_update(struct payment *p,
|
|||
newhint.timestamp = timestamp;
|
||||
newhint.scid.scid = scid;
|
||||
newhint.scid.dir = direction;
|
||||
newhint.overall_capacity = overall_capacity;
|
||||
newhint.capacity = overall_capacity;
|
||||
if (local) {
|
||||
newhint.local = tal(root->channel_hints, struct local_hint);
|
||||
assert(htlc_budget);
|
||||
|
@ -3539,7 +3539,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].total_amount = hint->capacity;
|
||||
paymod_log(p, LOG_DBG,
|
||||
"Found a direct channel (%s) with sufficient "
|
||||
"capacity, skipping route computation.",
|
||||
|
|
Loading…
Add table
Reference in a new issue