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

Function peer_connect_subd

connectd/multiplex.c:1234–1267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1232}
1233
1234void peer_connect_subd(struct daemon *daemon, const u8 *msg, int fd)
1235{
1236 struct node_id id;
1237 u64 counter;
1238 struct peer *peer;
1239 struct channel_id channel_id;
1240 struct subd *subd;
1241
1242 if (!fromwire_connectd_peer_connect_subd(msg, &id, &counter, &channel_id))
1243 master_badmsg(WIRE_CONNECTD_PEER_CONNECT_SUBD, msg);
1244
1245 /* Races can happen: this might be gone by now (or reconnected!). */
1246 peer = peer_htable_get(&daemon->peers, &id);
1247 if (!peer || peer->counter != counter) {
1248 close(fd);
1249 return;
1250 }
1251
1252 /* Could be disconnecting now */
1253 if (!peer->to_peer) {
1254 close(fd);
1255 return;
1256 }
1257
1258 /* If peer said something, we created this and queued msg. */
1259 subd = find_subd(peer, &channel_id);
1260 if (!subd)
1261 subd = new_subd(peer, &channel_id);
1262
1263 assert(!subd->conn);
1264
1265 /* This sets subd->conn inside subd_conn_init, and reparents subd! */
1266 io_new_conn(peer, fd, subd_conn_init, subd);
1267}
1268
1269/* Lightningd says to send a ping */
1270void send_manual_ping(struct daemon *daemon, const u8 *msg)

Callers 1

recv_peer_connect_subdFunction · 0.85

Calls 3

find_subdFunction · 0.85
new_subdFunction · 0.70
master_badmsgFunction · 0.50

Tested by

no test coverage detected