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

Function master_wait_sync_reply

channeld/channeld.c:968–1003  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

966
967/* This queues other traffic from the fd until we get reply. */
968static u8 *master_wait_sync_reply(const tal_t *ctx,
969 struct peer *peer,
970 const u8 *msg,
971 int replytype)
972{
973 u8 *reply;
974
975 status_debug("Sending master %u", fromwire_peektype(msg));
976
977 if (!wire_sync_write(MASTER_FD, msg))
978 status_failed(STATUS_FAIL_INTERNAL_ERROR,
979 "Could not set sync write to master: %s",
980 strerror(errno));
981
982 status_debug("... , awaiting %u", replytype);
983
984 for (;;) {
985 int type;
986
987 reply = wire_sync_read(ctx, MASTER_FD);
988 if (!reply)
989 status_failed(STATUS_FAIL_INTERNAL_ERROR,
990 "Could not set sync read from master: %s",
991 strerror(errno));
992 type = fromwire_peektype(reply);
993 if (type == replytype) {
994 status_debug("Got it!");
995 break;
996 }
997
998 status_debug("Nope, got %u instead", type);
999 msg_enqueue(peer->from_master, take(reply));
1000 }
1001
1002 return reply;
1003}
1004
1005/* Collect the htlcs for call to hsmd. */
1006static struct simple_htlc **collect_htlcs(const tal_t *ctx, const struct htlc **htlc_map)

Callers 3

send_commitFunction · 0.85
send_revocationFunction · 0.85

Calls 5

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

Tested by

no test coverage detected