Prioritize costs over distance, but bias to larger channels. */
| 731 | |
| 732 | /* Prioritize costs over distance, but bias to larger channels. */ |
| 733 | static u64 route_score(u32 distance, |
| 734 | struct amount_msat cost, |
| 735 | struct amount_msat risk, |
| 736 | int dir, |
| 737 | const struct gossmap_chan *c) |
| 738 | { |
| 739 | u64 cmsat = cost.millisatoshis; /* Raw: lengthy math */ |
| 740 | u64 rmsat = risk.millisatoshis; /* Raw: lengthy math */ |
| 741 | u64 bias = capacity_bias(global_gossmap, c, dir, cost); |
| 742 | |
| 743 | /* Smoothed harmonic mean to avoid division by 0 */ |
| 744 | u64 costs = (cmsat * rmsat * bias) / (cmsat + rmsat + bias + 1); |
| 745 | |
| 746 | if (costs > 0xFFFFFFFF) |
| 747 | costs = 0xFFFFFFFF; |
| 748 | return costs; |
| 749 | } |
| 750 | |
| 751 | static struct route_hop *route(const tal_t *ctx, |
| 752 | struct gossmap *gossmap, |
nothing calls this directly
no test coverage detected