mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +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:
parent
1f8a4bed39
commit
37971fb61f
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user