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

Function maybe_update_account

plugins/bkpr/recorder.c:1251–1352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1249}
1250
1251void maybe_update_account(struct db *db,
1252 struct account *acct,
1253 struct chain_event *e,
1254 const enum mvt_tag *tags,
1255 u32 closed_count,
1256 struct node_id *peer_id)
1257{
1258 struct db_stmt *stmt;
1259 bool updated = false;
1260
1261 for (size_t i = 0; i < tal_count(tags); i++) {
1262 switch (tags[i]) {
1263 case CHANNEL_PROPOSED:
1264 case CHANNEL_OPEN:
1265 updated = true;
1266 acct->open_event_db_id = tal(acct, u64);
1267 *acct->open_event_db_id = e->db_id;
1268 break;
1269 case CHANNEL_CLOSE:
1270 updated = true;
1271 acct->closed_event_db_id = tal(acct, u64);
1272 *acct->closed_event_db_id = e->db_id;
1273 break;
1274 case LEASED:
1275 updated = true;
1276 acct->leased = true;
1277 break;
1278 case OPENER:
1279 updated = true;
1280 acct->we_opened = true;
1281 break;
1282 case DEPOSIT:
1283 case WITHDRAWAL:
1284 case PENALTY:
1285 case INVOICE:
1286 case ROUTED:
1287 case PUSHED:
1288 case CHANNEL_TO_US:
1289 case HTLC_TIMEOUT:
1290 case HTLC_FULFILL:
1291 case HTLC_TX:
1292 case TO_WALLET:
1293 case IGNORED:
1294 case ANCHOR:
1295 case TO_THEM:
1296 case PENALIZED:
1297 case STOLEN:
1298 case TO_MINER:
1299 case LEASE_FEE:
1300 case STEALABLE:
1301 /* Ignored */
1302 break;
1303 }
1304 }
1305
1306 if (peer_id) {
1307 updated = true;
1308 acct->peer_id = tal_dup(acct, struct node_id, peer_id);

Callers 4

parse_and_log_chain_moveFunction · 0.85
test_account_crudFunction · 0.85

Calls 6

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

Tested by 2

test_account_crudFunction · 0.68