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

Function jcon_connected

lightningd/jsonrpc.c:1255–1287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1253}
1254
1255static struct io_plan *jcon_connected(struct io_conn *conn,
1256 struct lightningd *ld)
1257{
1258 struct json_connection *jcon;
1259
1260 /* We live as long as the connection, so we're not a leak. */
1261 jcon = notleak(tal(conn, struct json_connection));
1262 jcon->conn = conn;
1263 jcon->ld = ld;
1264 list_head_init(&jcon->jsouts);
1265 jcon->json_in = jsonrpc_io_new(jcon);
1266 jcon->notifications_enabled = false;
1267 jcon->db_batching = false;
1268 jcon->deprecated_ok = ld->deprecated_ok;
1269 list_head_init(&jcon->commands);
1270
1271 /* We want to log on destruction, so we free this in destructor. */
1272 jcon->log = new_logger(ld->log_book, ld->log_book, NULL, "jsonrpc#%i",
1273 io_conn_fd(conn));
1274
1275 tal_add_destructor(jcon, destroy_jcon);
1276
1277 /* Note that write_json and read_json alternate manually, by waking
1278 * each other. It would be simpler to not use a duplex io, and have
1279 * read_json parse one command, then io_wait() for command completion
1280 * and go to write_json.
1281 *
1282 * However, if we ever have notifications, this neat cmd-response
1283 * pattern would break down, so we use this trick. */
1284 return io_duplex(conn,
1285 read_json(conn, jcon),
1286 start_json_stream(conn, jcon));
1287}
1288
1289static struct io_plan *incoming_jcon_connected(struct io_conn *conn,
1290 struct lightningd *ld)

Callers 1

incoming_jcon_connectedFunction · 0.85

Calls 7

list_head_initFunction · 0.85
jsonrpc_io_newFunction · 0.85
io_conn_fdFunction · 0.85
io_duplexFunction · 0.85
read_jsonFunction · 0.85
start_json_streamFunction · 0.85
new_loggerFunction · 0.70

Tested by

no test coverage detected