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

Function wallet_save_network_event

wallet/wallet.c:7504–7536  ·  view source on GitHub ↗

Put the next network event into the db */

Source from the content-addressed store, hash-verified

7502
7503/* Put the next network event into the db */
7504void wallet_save_network_event(struct lightningd *ld,
7505 const struct node_id *peer_id,
7506 enum network_event etype,
7507 const char *reason,
7508 u64 duration_nsec,
7509 bool connect_attempted)
7510{
7511 u64 id;
7512 struct db_stmt *stmt;
7513
7514 stmt = db_prepare_v2(ld->wallet->db,
7515 SQL("INSERT INTO network_events ("
7516 " id,"
7517 " peer_id,"
7518 " type, "
7519 " timestamp,"
7520 " reason,"
7521 " duration_nsec,"
7522 " connect_attempted) VALUES "
7523 "(?, ?, ?, ?, ?, ?, ?);"));
7524 id = network_event_index_created(ld, etype, peer_id);
7525 db_bind_u64(stmt, id);
7526 db_bind_node_id(stmt, peer_id);
7527 db_bind_int(stmt, network_event_in_db(etype));
7528 db_bind_u64(stmt, clock_time().ts.tv_sec);
7529 if (reason)
7530 db_bind_text(stmt, reason);
7531 else
7532 db_bind_null(stmt);
7533 db_bind_u64(stmt, duration_nsec);
7534 db_bind_int(stmt, connect_attempted);
7535 db_exec_prepared_v2(take(stmt));
7536}
7537
7538bool wallet_network_event_delete(struct wallet *w, u64 created_index)
7539{

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