plugins/pay: fix capacity bias.

With the warning that we were trying to put "inf" into a u64, we can
see that this calculation was wrong to use integers!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-04-01 14:12:23 +10:30
parent 1f8a4bed39
commit 37971fb61f

View File

@ -729,13 +729,14 @@ static u64 capacity_bias(const struct gossmap *map,
struct amount_msat amount)
{
struct amount_sat capacity;
u64 capmsat, amtmsat = amount.millisatoshis; /* Raw: lengthy math */
u64 amtmsat = amount.millisatoshis; /* Raw: lengthy math */
double capmsat;
/* Can fail in theory if gossmap changed underneath. */
if (!gossmap_chan_get_capacity(map, c, &capacity))
return 0;
capmsat = capacity.satoshis * 1000; /* Raw: lengthy math */
capmsat = (double)capacity.satoshis * 1000; /* Raw: lengthy math */
return -log((capmsat + 1 - amtmsat) / (capmsat + 1));
}