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

Function handle_peer_in

openingd/openingd.c:1311–1339  ·  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

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

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