| 576 | } |
| 577 | |
| 578 | static const struct node_id *random_peers(const tal_t *ctx, |
| 579 | const struct chanbackup *cb) |
| 580 | { |
| 581 | struct peer_map_iter it; |
| 582 | const struct node_id *peer; |
| 583 | struct node_id *ids = tal_arr(ctx, struct node_id, 0); |
| 584 | |
| 585 | /* Simple case: pick all of them */ |
| 586 | if (peer_map_count(cb->peers) <= NUM_BACKUP_PEERS) { |
| 587 | for (peer = peer_map_first(cb->peers, &it); |
| 588 | peer; |
| 589 | peer = peer_map_next(cb->peers, &it)) { |
| 590 | tal_arr_expand(&ids, *peer); |
| 591 | } |
| 592 | } else { |
| 593 | while (peer_map_count(cb->peers) < NUM_BACKUP_PEERS) { |
| 594 | peer = peer_map_pick(cb->peers, pseudorand_u64(), &it); |
| 595 | if (already_have_node_id(ids, peer)) |
| 596 | continue; |
| 597 | tal_arr_expand(&ids, *peer); |
| 598 | } |
| 599 | } |
| 600 | return ids; |
| 601 | } |
| 602 | |
| 603 | static struct command_result *send_to_peers(struct command *cmd) |
| 604 | { |
no test coverage detected