What is capacity of peer attached to chan #n? */
| 439 | |
| 440 | /* What is capacity of peer attached to chan #n? */ |
| 441 | static 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 */ |
no test coverage detected