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

Function wallet_save_network_event

wallet/wallet.c:7467–7499  ·  view source on GitHub ↗

Put the next network event into the db */

Source from the content-addressed store, hash-verified

7465
7466/* Put the next network event into the db */
7467void wallet_save_network_event(struct lightningd *ld,
7468 const struct node_id *peer_id,
7469 enum network_event etype,
7470 const char *reason,
7471 u64 duration_nsec,
7472 bool connect_attempted)
7473{
7474 u64 id;
7475 struct db_stmt *stmt;
7476
7477 stmt = db_prepare_v2(ld->wallet->db,
7478 SQL("INSERT INTO network_events ("
7479 " id,"
7480 " peer_id,"
7481 " type, "
7482 " timestamp,"
7483 " reason,"
7484 " duration_nsec,"
7485 " connect_attempted) VALUES "
7486 "(?, ?, ?, ?, ?, ?, ?);"));
7487 id = network_event_index_created(ld, etype, peer_id);
7488 db_bind_u64(stmt, id);
7489 db_bind_node_id(stmt, peer_id);
7490 db_bind_int(stmt, network_event_in_db(etype));
7491 db_bind_u64(stmt, clock_time().ts.tv_sec);
7492 if (reason)
7493 db_bind_text(stmt, reason);
7494 else
7495 db_bind_null(stmt);
7496 db_bind_u64(stmt, duration_nsec);
7497 db_bind_int(stmt, connect_attempted);
7498 db_exec_prepared_v2(take(stmt));
7499}
7500
7501bool wallet_network_event_delete(struct wallet *w, u64 created_index)
7502{

Callers

nothing calls this directly

Calls 9

db_bind_u64Function · 0.85
db_bind_node_idFunction · 0.85
db_bind_intFunction · 0.85
network_event_in_dbFunction · 0.85
clock_timeFunction · 0.85
db_bind_textFunction · 0.85
db_bind_nullFunction · 0.85
db_exec_prepared_v2Function · 0.85

Tested by

no test coverage detected