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

Function start_json_stream

lightningd/jsonrpc.c:1143–1173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1141 struct json_connection *jcon);
1142
1143static struct io_plan *start_json_stream(struct io_conn *conn,
1144 struct json_connection *jcon)
1145{
1146 struct json_stream *js;
1147
1148 /* If something has created an output buffer, start streaming. */
1149 js = list_top(&jcon->jsouts, struct json_stream, list);
1150 if (js) {
1151 size_t len;
1152 const char *p = json_out_contents(js->jout, &len);
1153 if (len)
1154 log_io(jcon->log, LOG_IO_OUT, NULL, "", p, len);
1155 return json_stream_output(js, conn,
1156 stream_out_complete, jcon);
1157 }
1158
1159 /* Tell reader it can run next command. */
1160 io_wake(conn);
1161
1162 /* Once the stop_conn conn is drained, we can shut down. */
1163 if (jcon->ld->stop_conn == conn
1164 && (jcon->ld->state == LD_STATE_RUNNING || jcon->ld->state == LD_STATE_GRACE)) {
1165 /* Return us to toplevel lightningd.c */
1166 log_debug(jcon->ld->log, "io_break: %s", __func__);
1167 io_break(jcon->ld);
1168 /* We never come back. */
1169 return io_out_wait(conn, conn, io_never, conn);
1170 }
1171
1172 return io_out_wait(conn, jcon, start_json_stream, jcon);
1173}
1174
1175/* Command has completed writing, and we've written it all out to conn. */
1176static struct io_plan *stream_out_complete(struct io_conn *conn,

Callers 2

stream_out_completeFunction · 0.85
jcon_connectedFunction · 0.85

Calls 4

json_out_contentsFunction · 0.85
io_wakeFunction · 0.85
io_breakFunction · 0.85
log_ioFunction · 0.70

Tested by

no test coverage detected