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

Function wallet_save_network_event

wallet/wallet.c:7527–7559  ·  view source on GitHub ↗

Put the next network event into the db */

Source from the content-addressed store, hash-verified

7525
7526/* Put the next network event into the db */
7527void wallet_save_network_event(struct lightningd *ld,
7528 const struct node_id *peer_id,
7529 enum network_event etype,
7530 const char *reason,
7531 u64 duration_nsec,
7532 bool connect_attempted)
7533{
7534 u64 id;
7535 struct db_stmt *stmt;
7536
7537 stmt = db_prepare_v2(ld->wallet->db,
7538 SQL("INSERT INTO network_events ("
7539 " id,"
7540 " peer_id,"
7541 " type, "
7542 " timestamp,"
7543 " reason,"
7544 " duration_nsec,"
7545 " connect_attempted) VALUES "
7546 "(?, ?, ?, ?, ?, ?, ?);"));
7547 id = network_event_index_created(ld, etype, peer_id);
7548 db_bind_u64(stmt, id);
7549 db_bind_node_id(stmt, peer_id);
7550 db_bind_int(stmt, network_event_in_db(etype));
7551 db_bind_u64(stmt, clock_time().ts.tv_sec);
7552 if (reason)
7553 db_bind_text(stmt, reason);
7554 else
7555 db_bind_null(stmt);
7556 db_bind_u64(stmt, duration_nsec);
7557 db_bind_int(stmt, connect_attempted);
7558 db_exec_prepared_v2(take(stmt));
7559}
7560
7561bool wallet_network_event_delete(struct wallet *w, u64 created_index)
7562{

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