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

Function start_json_stream

lightningd/jsonrpc.c:1139–1169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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