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

Function master_wait_sync_reply

channeld/channeld.c:929–964  ·  view source on GitHub ↗

This queues other traffic from the fd until we get reply. */

Source from the content-addressed store, hash-verified

927
928/* This queues other traffic from the fd until we get reply. */
929static u8 *master_wait_sync_reply(const tal_t *ctx,
930 struct peer *peer,
931 const u8 *msg,
932 int replytype)
933{
934 u8 *reply;
935
936 status_debug("Sending master %u", fromwire_peektype(msg));
937
938 if (!wire_sync_write(MASTER_FD, msg))
939 status_failed(STATUS_FAIL_INTERNAL_ERROR,
940 "Could not set sync write to master: %s",
941 strerror(errno));
942
943 status_debug("... , awaiting %u", replytype);
944
945 for (;;) {
946 int type;
947
948 reply = wire_sync_read(ctx, MASTER_FD);
949 if (!reply)
950 status_failed(STATUS_FAIL_MASTER_IO,
951 "Could not set sync read from master: %s",
952 strerror(errno));
953 type = fromwire_peektype(reply);
954 if (type == replytype) {
955 status_debug("Got it!");
956 break;
957 }
958
959 status_debug("Nope, got %u instead", type);
960 msg_enqueue(peer->from_master, take(reply));
961 }
962
963 return reply;
964}
965
966static struct hsm_htlc *collect_htlcs(const tal_t *ctx,
967 const struct htlc **htlc_map)

Callers 6

send_commit_partFunction · 0.85
send_revocationFunction · 0.85
bitcoin_tx_from_txidFunction · 0.85
splice_accepterFunction · 0.85

Calls 5

fromwire_peektypeFunction · 0.85
msg_enqueueFunction · 0.85
wire_sync_writeFunction · 0.50
status_failedFunction · 0.50
wire_sync_readFunction · 0.50

Tested by

no test coverage detected