| 887 | } |
| 888 | |
| 889 | static void uniquify_node_ids(struct node_id **ids) |
| 890 | { |
| 891 | size_t dst, src; |
| 892 | |
| 893 | /* BOLT #7: |
| 894 | * - SHOULD avoid sending duplicate `node_announcements` in |
| 895 | * response to a single `query_short_channel_ids`. |
| 896 | */ |
| 897 | /* ccan/asort is a typesafe qsort wrapper: like most ccan modules |
| 898 | * it eschews exposing 'void *' pointers and ensures that the |
| 899 | * callback function and its arguments match types correctly. */ |
| 900 | asort(*ids, tal_count(*ids), pubkey_order, NULL); |
| 901 | |
| 902 | /* Compact the array */ |
| 903 | for (dst = 0, src = 0; src < tal_count(*ids); src++) { |
| 904 | if (dst && node_id_eq(&(*ids)[dst-1], &(*ids)[src])) |
| 905 | continue; |
| 906 | (*ids)[dst++] = (*ids)[src]; |
| 907 | } |
| 908 | |
| 909 | /* And trim to length, so tal_count() gives correct answer. */ |
| 910 | tal_resize(ids, dst); |
| 911 | } |
| 912 | |
| 913 | /* We are fairly careful to avoid the peer DoSing us with channel queries: |
| 914 | * this routine sends information about a single short_channel_id, unless |
no test coverage detected