| 1004 | } |
| 1005 | |
| 1006 | struct db *db_setup(const tal_t *ctx, struct lightningd *ld, |
| 1007 | const struct ext_key *bip32_base) |
| 1008 | { |
| 1009 | struct db *db = db_open(ctx, ld->wallet_dsn); |
| 1010 | bool migrated; |
| 1011 | |
| 1012 | db->report_changes_fn = plugin_hook_db_sync; |
| 1013 | |
| 1014 | db_begin_transaction(db); |
| 1015 | db->data_version = db_data_version_get(db); |
| 1016 | |
| 1017 | migrated = db_migrate(ld, db, bip32_base); |
| 1018 | |
| 1019 | db_commit_transaction(db); |
| 1020 | |
| 1021 | /* This needs to be done outside a transaction, apparently. |
| 1022 | * It's a good idea to do this every so often, and on db |
| 1023 | * upgrade is a reasonable time. */ |
| 1024 | if (migrated && !db->config->vacuum_fn(db)) |
| 1025 | db_fatal("Error vacuuming db: %s", db->error); |
| 1026 | |
| 1027 | return db; |
| 1028 | } |
| 1029 | |
| 1030 | /* Will apply the current config fee settings to all channels */ |
| 1031 | static void migrate_pr2342_feerate_per_channel(struct lightningd *ld, struct db *db, |
no test coverage detected