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

Function check_capacity

plugins/askrene/child/explain_failure.c:127–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127static const char *check_capacity(const tal_t *ctx,
128 const struct route_query *rq,
129 const struct gossmap_node *node,
130 enum node_direction node_direction,
131 struct amount_msat amount,
132 const char *name)
133{
134 struct node_stats stats;
135
136 node_stats(rq, node, node_direction, &stats);
137 if (amount_msat_greater(amount, stats.total.capacity)) {
138 return child_log(ctx, LOG_DBG,
139 NO_USABLE_PATHS_STRING
140 " Total %s capacity is only %s"
141 " (in %zu channels).",
142 name,
143 fmt_amount_msat(tmpctx, stats.total.capacity),
144 stats.total.num_channels);
145 }
146 if (amount_msat_greater(amount, stats.gossip_known.capacity)) {
147 return child_log(ctx, LOG_DBG,
148 NO_USABLE_PATHS_STRING
149 " Missing gossip for %s: only known %zu/%zu channels, leaving capacity only %s of %s.",
150 name,
151 stats.gossip_known.num_channels,
152 stats.total.num_channels,
153 fmt_amount_msat(tmpctx, stats.gossip_known.capacity),
154 fmt_amount_msat(tmpctx, stats.total.capacity));
155 }
156 if (amount_msat_greater(amount, stats.enabled.capacity)) {
157 /* Common case: one channel, disabled */
158 if (stats.enabled.num_channels == 0) {
159 return child_log(ctx, LOG_DBG,
160 NO_USABLE_PATHS_STRING
161 " All %zu channels to the %s are disabled.",
162 stats.total.num_channels,
163 name);
164 }
165 return child_log(ctx, LOG_DBG,
166 NO_USABLE_PATHS_STRING
167 " %zu of %zu channels to %s are disabled, leaving capacity only %s of %s.",
168 stats.total.num_channels - stats.enabled.num_channels,
169 stats.total.num_channels,
170 name,
171 fmt_amount_msat(tmpctx, stats.enabled.capacity),
172 fmt_amount_msat(tmpctx, stats.total.capacity));
173 }
174 return NULL;
175}
176
177/* Return description of why scidd is disabled scidd */
178static const char *describe_disabled(const tal_t *ctx,

Callers 1

explain_failureFunction · 0.85

Calls 4

amount_msat_greaterFunction · 0.85
child_logFunction · 0.85
node_statsFunction · 0.70
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected