Rene Pickhardt: * * Btw the linear term of the Taylor series of -log((c+1-x)/(c+1)) is 1/(c+1) * meaning that another suitable Weight for Dijkstra would be amt/(c+1) + * \mu*fee(amt) which is the linearized version which for small amounts and * suitable value of \mu should be good enough) */
| 714 | * suitable value of \mu should be good enough) |
| 715 | */ |
| 716 | static u64 capacity_bias(const struct gossmap *map, |
| 717 | const struct gossmap_chan *c, |
| 718 | int dir, |
| 719 | struct amount_msat amount) |
| 720 | { |
| 721 | struct amount_sat capacity; |
| 722 | u64 capmsat, amtmsat = amount.millisatoshis; /* Raw: lengthy math */ |
| 723 | |
| 724 | /* Can fail in theory if gossmap changed underneath. */ |
| 725 | if (!gossmap_chan_get_capacity(map, c, &capacity)) |
| 726 | return 0; |
| 727 | |
| 728 | capmsat = capacity.satoshis * 1000; /* Raw: lengthy math */ |
| 729 | return -log((capmsat + 1 - amtmsat) / (capmsat + 1)); |
| 730 | } |
| 731 | |
| 732 | /* Prioritize costs over distance, but bias to larger channels. */ |
| 733 | static u64 route_score(u32 distance, |
no test coverage detected