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

Function db_setup

plugins/bkpr/db.c:205–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203#endif /* DB_FATAL */
204
205struct db *db_setup(const tal_t *ctx, struct plugin *p,
206 const char *db_dsn, bool *created)
207{
208 bool migrated;
209 struct db *db;
210
211 /* Set global for db_fatal */
212 plugin = p;
213 db = db_open(ctx, db_dsn);
214 db->report_changes_fn = NULL;
215
216 db_begin_transaction(db);
217 migrated = db_migrate(p, db, created);
218 db->data_version = db_data_version_get(db);
219 db_commit_transaction(db);
220
221 /* This needs to be done outside a transaction, apparently.
222 * It's a good idea to do this every so often, and on db
223 * upgrade is a reasonable time. */
224 if (migrated && !db->config->vacuum_fn(db))
225 db_fatal("Error vacuuming db: %s", db->error);
226
227 return db;
228}

Callers 9

initFunction · 0.70
test_channel_rebalancesFunction · 0.50
test_channel_event_crudFunction · 0.50
test_chain_event_crudFunction · 0.50
test_account_balancesFunction · 0.50
test_account_crudFunction · 0.50

Calls 5

db_openFunction · 0.85
db_data_version_getFunction · 0.85
db_migrateFunction · 0.70
db_fatalFunction · 0.70
db_commit_transactionFunction · 0.50

Tested by 8

test_channel_rebalancesFunction · 0.40
test_channel_event_crudFunction · 0.40
test_chain_event_crudFunction · 0.40
test_account_balancesFunction · 0.40
test_account_crudFunction · 0.40