| 2071 | } |
| 2072 | |
| 2073 | static void setup_peer(struct peer *peer, u32 delay) |
| 2074 | { |
| 2075 | struct channel *channel; |
| 2076 | struct channel_inflight *inflight; |
| 2077 | struct lightningd *ld = peer->ld; |
| 2078 | bool connect = false; |
| 2079 | |
| 2080 | list_for_each(&peer->channels, channel, list) { |
| 2081 | if (channel_unsaved(channel)) |
| 2082 | continue; |
| 2083 | /* Watching lockin may be unnecessary, but it's harmless. */ |
| 2084 | channel_watch_funding(ld, channel); |
| 2085 | |
| 2086 | /* Also watch any inflight txs */ |
| 2087 | list_for_each(&channel->inflights, inflight, list) { |
| 2088 | /* Don't double watch the txid that's also in |
| 2089 | * channel->funding_txid */ |
| 2090 | if (bitcoin_txid_eq(&channel->funding.txid, |
| 2091 | &inflight->funding->outpoint.txid)) |
| 2092 | continue; |
| 2093 | |
| 2094 | channel_watch_inflight(ld, channel, inflight); |
| 2095 | } |
| 2096 | if (channel_active(channel)) |
| 2097 | connect = true; |
| 2098 | } |
| 2099 | |
| 2100 | /* Make sure connectd knows to try reconnecting. */ |
| 2101 | if (connect) { |
| 2102 | /* To delay, make it seem like we just connected. */ |
| 2103 | if (delay > 0) { |
| 2104 | peer->reconnect_delay = delay; |
| 2105 | peer->last_connect_attempt = time_now(); |
| 2106 | } |
| 2107 | try_reconnect(peer, peer, &peer->addr); |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | void setup_peers(struct lightningd *ld) |
| 2112 | { |
no test coverage detected