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

Function sd_msg_read

lightningd/subd.c:483–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd)
484{
485 int type = fromwire_peektype(sd->msg_in);
486 struct subd_req *sr;
487 struct db *db = sd->ld->wallet->db;
488 struct io_plan *plan;
489 unsigned int i;
490 bool freed = false;
491
492 /* Everything we do, we wrap in a database transaction */
493 db_begin_transaction(db);
494
495 if (type == -1)
496 goto malformed;
497
498 /* First, check for replies. */
499 sr = get_req(sd, type);
500 if (sr) {
501 if (sr->num_reply_fds && sd->fds_in == NULL) {
502 plan = sd_collect_fds(conn, sd, sr->num_reply_fds);
503 goto out;
504 }
505
506 assert(sr->num_reply_fds == tal_count(sd->fds_in));
507 plan = sd_msg_reply(conn, sd, sr);
508 goto out;
509 }
510
511 /* If not stolen, we'll free this later. */
512 tal_steal(tmpctx, sd->msg_in);
513
514 /* We handle status messages ourselves. */
515 switch ((enum status_wire)type) {
516 case WIRE_STATUS_LOG:
517 case WIRE_STATUS_IO:
518 if (!log_status_msg(sd->log, sd->node_id, sd->msg_in))
519 goto malformed;
520 goto next;
521 case WIRE_STATUS_FAIL:
522 if (!log_status_fail(sd, sd->msg_in))
523 goto malformed;
524 goto close;
525 case WIRE_STATUS_PEER_CONNECTION_LOST:
526 if (!sd->channel)
527 goto malformed;
528 log_info(sd->log, "Peer connection lost");
529 goto close;
530 case WIRE_STATUS_PEER_BILLBOARD:
531 if (!sd->channel)
532 goto malformed;
533 if (!handle_set_billboard(sd, sd->msg_in))
534 goto malformed;
535 goto next;
536 case WIRE_STATUS_VERSION:
537 if (!handle_version(sd, sd->msg_in))
538 goto close;
539 goto next;
540 }

Callers 1

read_fdsFunction · 0.85

Calls 14

fromwire_peektypeFunction · 0.85
get_reqFunction · 0.85
sd_collect_fdsFunction · 0.85
sd_msg_replyFunction · 0.85
log_status_failFunction · 0.85
log_infoClass · 0.85
handle_set_billboardFunction · 0.85
handle_versionFunction · 0.85
handle_peer_errorFunction · 0.85
tal_freeFunction · 0.85
subdaemon_malformed_msgFunction · 0.85
io_closeFunction · 0.85

Tested by

no test coverage detected