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

Function peer_capacity

plugins/topology.c:441–461  ·  view source on GitHub ↗

What is capacity of peer attached to chan #n? */

Source from the content-addressed store, hash-verified

439
440/* What is capacity of peer attached to chan #n? */
441static struct amount_msat peer_capacity(const struct gossmap *gossmap,
442 const struct gossmap_node *me,
443 const struct gossmap_node *peer,
444 const struct gossmap_chan *ourchan)
445{
446 struct amount_msat capacity = AMOUNT_MSAT(0);
447
448 for (size_t i = 0; i < peer->num_chans; i++) {
449 int dir;
450 struct gossmap_chan *c;
451 c = gossmap_nth_chan(gossmap, peer, i, &dir);
452 if (c == ourchan)
453 continue;
454 if (!c->half[!dir].enabled)
455 continue;
456 if (!amount_msat_accumulate(&capacity,
457 amount_msat(fp16_to_u64(c->half[!dir].htlc_max))))
458 continue;
459 }
460 return capacity;
461}
462
463/* For deterministic results with bolt12/11 routes, we only return a
464 * single candidate: choose the one with most capacity */

Callers 2

best_candidateFunction · 0.85

Calls 4

gossmap_nth_chanFunction · 0.85
amount_msat_accumulateFunction · 0.85
fp16_to_u64Function · 0.85
amount_msatClass · 0.70

Tested by

no test coverage detected