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

Function capacity_bias

plugins/libplugin-pay.c:716–730  ·  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

714 * suitable value of \mu should be good enough)
715 */
716static 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. */
733static u64 route_score(u32 distance,

Callers 1

route_scoreFunction · 0.85

Calls 2

logClass · 0.50

Tested by

no test coverage detected