MCPcopy Create free account
hub / github.com/ElementsProject/lightning / capacity_bias

Function capacity_bias

plugins/libplugin-pay.c:743–755  ·  view source on GitHub ↗

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) */

Source from the content-addressed store, hash-verified

741 * suitable value of \mu should be good enough)
742 */
743static 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. */
758static u64 route_score(struct amount_msat fee,

Callers 1

route_scoreFunction · 0.70

Calls 1

Tested by

no test coverage detected