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

Function send_response

plugins/commando.c:118–156  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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