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

Function refresh_tables

plugins/sql.c:1371–1405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1369}
1370
1371static struct command_result *refresh_tables(struct command *cmd,
1372 struct db_query *dbq)
1373{
1374 struct table_desc *td;
1375
1376 if (tal_count(dbq->tables) == 0)
1377 return refresh_complete(cmd, dbq);
1378
1379 td = dbq->tables[0];
1380
1381 /* If it's currently being refreshed, wait */
1382 if (td->refreshing) {
1383 struct refresh_waiter *rw = tal(cmd, struct refresh_waiter);
1384 rw->cmd = cmd;
1385 rw->dbq = dbq;
1386 list_add(&td->refresh_waiters, &rw->list);
1387 return command_still_pending(cmd);
1388 }
1389
1390 if (td->refresh_needs == REFRESH_UNNECESSARY)
1391 return next_refresh(cmd, dbq);
1392
1393 td->refreshing = true;
1394 td->refresh_start = time_mono();
1395
1396 /* The first time, we may need to install watches */
1397 if (!td->populated && td->waitname) {
1398 /* We will initialize td->last_created_index as we read them in */
1399 watch_init(cmd, td, "created", NULL);
1400 watch_init(cmd, td, "updated", &td->last_updated_index);
1401 watch_init(cmd, td, "deleted", NULL);
1402 }
1403
1404 return td->refresh(cmd, dbq->tables[0], dbq);
1405}
1406
1407static struct command_result *json_sql(struct command *cmd,
1408 const char *buffer,

Callers 3

next_refreshFunction · 0.85
one_refresh_doneFunction · 0.85
json_sqlFunction · 0.85

Calls 6

refresh_completeFunction · 0.85
next_refreshFunction · 0.85
time_monoFunction · 0.85
watch_initFunction · 0.85
refreshMethod · 0.80
command_still_pendingFunction · 0.70

Tested by

no test coverage detected