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

Function send_response

plugins/commando.c:115–153  ·  view source on GitHub ↗

Calls itself repeatedly: first time, result is NULL */

Source from the content-addressed store, hash-verified

113
114/* Calls itself repeatedly: first time, result is NULL */
115static struct command_result *send_response(struct command *cmd,
116 const char *method UNUSED,
117 const char *buf UNUSED,
118 const jsmntok_t *result,
119 struct reply *reply)
120{
121 size_t msglen = reply->len - reply->off;
122 u8 *cmd_msg;
123 enum commando_msgtype msgtype;
124 struct out_req *req;
125
126 /* Limit is 64k, but there's a little overhead */
127 if (msglen > 65000) {
128 msglen = 65000;
129 msgtype = COMMANDO_MSG_REPLY_CONTINUES;
130 } else {
131 if (msglen == 0) {
132 tal_free(reply);
133 return command_hook_success(cmd);
134 }
135 msgtype = COMMANDO_MSG_REPLY_TERM;
136 }
137
138 cmd_msg = tal_arr(NULL, u8, 0);
139 towire_u16(&cmd_msg, msgtype);
140 towire_u64(&cmd_msg, reply->incoming->id);
141 towire(&cmd_msg, reply->buf + reply->off, msglen);
142 reply->off += msglen;
143
144 req = jsonrpc_request_start(cmd, "sendcustommsg",
145 send_response, send_response,
146 reply);
147 json_add_node_id(req->js, "node_id", &reply->incoming->peer);
148 json_add_hex_talarr(req->js, "msg", cmd_msg);
149 tal_free(cmd_msg);
150 send_outreq(req);
151
152 return command_still_pending(cmd);
153}
154
155static struct command_result *cmd_done(struct command *command,
156 const char *method,

Callers 2

cmd_doneFunction · 0.85
commando_errorFunction · 0.85

Calls 9

tal_freeFunction · 0.85
json_add_node_idFunction · 0.85
json_add_hex_talarrFunction · 0.85
command_hook_successFunction · 0.70
send_outreqFunction · 0.70
command_still_pendingFunction · 0.70
towire_u16Function · 0.50
towire_u64Function · 0.50
towireFunction · 0.50

Tested by

no test coverage detected