mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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:
@@ -729,13 +729,14 @@ static u64 capacity_bias(const struct gossmap *map,
|
|||||||
struct amount_msat amount)
|
struct amount_msat amount)
|
||||||
{
|
{
|
||||||
struct amount_sat capacity;
|
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. */
|
/* Can fail in theory if gossmap changed underneath. */
|
||||||
if (!gossmap_chan_get_capacity(map, c, &capacity))
|
if (!gossmap_chan_get_capacity(map, c, &capacity))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
capmsat = capacity.satoshis * 1000; /* Raw: lengthy math */
|
capmsat = (double)capacity.satoshis * 1000; /* Raw: lengthy math */
|
||||||
return -log((capmsat + 1 - amtmsat) / (capmsat + 1));
|
return -log((capmsat + 1 - amtmsat) / (capmsat + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user