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

Function handle_peer_in

openingd/openingd.c:1308–1336  ·  view source on GitHub ↗

~ Standard "peer sent a message, handle it" demuxer. Though it really only * handles one message, we use the standard form as principle of least * surprise. */

Source from the content-addressed store, hash-verified

1306 * handles one message, we use the standard form as principle of least
1307 * surprise. */
1308static u8 *handle_peer_in(struct state *state)
1309{
1310 u8 *msg = peer_read(tmpctx, state->pps);
1311 enum peer_wire t = fromwire_peektype(msg);
1312 struct channel_id channel_id;
1313 bool extracted;
1314
1315 if (t == WIRE_OPEN_CHANNEL)
1316 return fundee_channel(state, msg);
1317
1318 /* Handles error cases. */
1319 if (handle_peer_error_or_warning(state->pps, msg))
1320 return NULL;
1321
1322 extracted = extract_channel_id(msg, &channel_id);
1323
1324 peer_write(state->pps,
1325 take(towire_warningfmt(NULL,
1326 extracted ? &channel_id : NULL,
1327 "Unexpected message %s: %s",
1328 peer_wire_name(t),
1329 tal_hex(tmpctx, msg))));
1330
1331 /* FIXME: We don't actually want master to try to send an
1332 * error, since peer is transient. This is a hack.
1333 */
1334 status_broken("Unexpected message %s", peer_wire_name(t));
1335 peer_failed_connection_lost();
1336}
1337
1338static void handle_dev_memleak(struct state *state, const u8 *msg)
1339{

Callers 1

mainFunction · 0.70

Calls 9

peer_readFunction · 0.85
fromwire_peektypeFunction · 0.85
fundee_channelFunction · 0.85
extract_channel_idFunction · 0.85
peer_writeFunction · 0.85
tal_hexFunction · 0.85
towire_warningfmtFunction · 0.50

Tested by

no test coverage detected