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

Function jcon_connected

lightningd/jsonrpc.c:1259–1291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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