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) */
| 741 | * suitable value of \mu should be good enough) |
| 742 | */ |
| 743 | static double capacity_bias(const struct gossmap *map, |
| 744 | const struct gossmap_chan *c, |
| 745 | int dir, |
| 746 | struct amount_msat amount) |
| 747 | { |
| 748 | u64 amtmsat = amount.millisatoshis; /* Raw: lengthy math */ |
| 749 | double capmsat; |
| 750 | |
| 751 | /* Can fail in theory if gossmap changed underneath. */ |
| 752 | capmsat = (double)gossmap_chan_get_capacity(map, c).millisatoshis; /* Raw: log */ |
| 753 | |
| 754 | return -log((capmsat + 1 - amtmsat) / (capmsat + 1)); |
| 755 | } |
| 756 | |
| 757 | /* Prioritize costs over distance, but bias to larger channels. */ |
| 758 | static u64 route_score(struct amount_msat fee, |
no test coverage detected