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

Function peer_capacity

plugins/topology.c:532–553  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

530
531/* What is capacity of peer attached to chan #n? */
532static struct amount_msat peer_capacity(const struct gossmap *gossmap,
533 const struct gossmap_node *me,
534 const struct gossmap_node *peer,
535 const struct gossmap_chan *ourchan)
536{
537 struct amount_msat capacity = AMOUNT_MSAT(0);
538
539 for (size_t i = 0; i < peer->num_chans; i++) {
540 int dir;
541 struct gossmap_chan *c;
542 c = gossmap_nth_chan(gossmap, peer, i, &dir);
543 if (c == ourchan)
544 continue;
545 if (!c->half[!dir].enabled)
546 continue;
547 if (!amount_msat_add(
548 &capacity, capacity,
549 amount_msat(fp16_to_u64(c->half[!dir].htlc_max))))
550 continue;
551 }
552 return capacity;
553}
554
555static struct command_result *json_listincoming(struct command *cmd,
556 const char *buffer,

Callers 1

json_listincomingFunction · 0.85

Calls 4

gossmap_nth_chanFunction · 0.85
amount_msat_addFunction · 0.85
fp16_to_u64Function · 0.85
amount_msatClass · 0.70

Tested by

no test coverage detected