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

Function handle_peer_in

openingd/openingd.c:1316–1344  ·  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

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

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