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

Function handle_peer_in

openingd/openingd.c:1327–1355  ·  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

1325 * handles one message, we use the standard form as principle of least
1326 * surprise. */
1327static u8 *handle_peer_in(struct state *state)
1328{
1329 u8 *msg = peer_read(tmpctx, state->pps);
1330 enum peer_wire t = fromwire_peektype(msg);
1331 struct channel_id channel_id;
1332 bool extracted;
1333
1334 if (t == WIRE_OPEN_CHANNEL)
1335 return fundee_channel(state, msg);
1336
1337 /* Handles error cases. */
1338 if (handle_peer_error(state->pps, &state->channel_id, msg))
1339 return NULL;
1340
1341 extracted = extract_channel_id(msg, &channel_id);
1342
1343 peer_write(state->pps,
1344 take(towire_warningfmt(NULL,
1345 extracted ? &channel_id : NULL,
1346 "Unexpected message %s: %s",
1347 peer_wire_name(t),
1348 tal_hex(tmpctx, msg))));
1349
1350 /* FIXME: We don't actually want master to try to send an
1351 * error, since peer is transient. This is a hack.
1352 */
1353 status_broken("Unexpected message %s", peer_wire_name(t));
1354 peer_failed_connection_lost();
1355}
1356
1357/* Memory leak detection is DEVELOPER-only because we go to great lengths to
1358 * record the backtrace when allocations occur: without that, the leak

Callers 1

mainFunction · 0.70

Calls 10

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

Tested by

no test coverage detected