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

Function setup_peer

lightningd/peer_control.c:3128–3192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3126}
3127
3128static void setup_peer(struct peer *peer)
3129{
3130 struct channel *channel;
3131 struct channel_inflight *inflight;
3132 struct lightningd *ld = peer->ld;
3133 bool connect = false, important = false;
3134
3135 list_for_each(&peer->channels, channel, list) {
3136 switch (channel->state) {
3137 case DUALOPEND_OPEN_INIT:
3138 case DUALOPEND_OPEN_COMMIT_READY:
3139 case DUALOPEND_OPEN_COMMITTED:
3140 /* Nothing to watch */
3141 continue;
3142
3143 /* Normal cases where we watch funding */
3144 case CHANNELD_AWAITING_LOCKIN:
3145 case CHANNELD_NORMAL:
3146 case CHANNELD_SHUTTING_DOWN:
3147 case CLOSINGD_SIGEXCHANGE:
3148 /* We still want to watch spend, to tell onchaind: */
3149 case CLOSINGD_COMPLETE:
3150 case AWAITING_UNILATERAL:
3151 case FUNDING_SPEND_SEEN:
3152 case ONCHAIN:
3153 case CLOSED:
3154 channel_watch_funding(ld, channel);
3155 break;
3156
3157 /* We need to watch all inflights which may open channel */
3158 case DUALOPEND_AWAITING_LOCKIN:
3159 list_for_each(&channel->inflights, inflight, list)
3160 watch_opening_inflight(ld, inflight);
3161 break;
3162
3163 /* We need to watch all inflights which may splice, and the
3164 * current funding, which is live until one of them does. */
3165 case CHANNELD_AWAITING_SPLICE:
3166 channel_watch_funding(ld, channel);
3167 list_for_each(&channel->inflights, inflight, list)
3168 watch_splice_inflight(ld, inflight);
3169 break;
3170 }
3171
3172 /* Don't reconnect for private channels if --dev-no-reconnect-private */
3173 if (!channel->peer->ld->reconnect_private
3174 && !(channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL))
3175 continue;
3176
3177 if (channel_state_wants_peercomms(channel->state)
3178 && !ignore_idle_channel(ld, channel))
3179 connect = true;
3180 if (channel_important_filter(channel, NULL))
3181 important = true;
3182
3183 channel_watch_inflight_outs(ld, channel);
3184 }
3185

Callers 1

setup_peersFunction · 0.85

Calls 8

channel_watch_fundingFunction · 0.85
ignore_idle_channelFunction · 0.85
watch_opening_inflightFunction · 0.70
watch_splice_inflightFunction · 0.70
channel_important_filterFunction · 0.70
connectd_connect_to_peerFunction · 0.70

Tested by

no test coverage detected