mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-26 01:04:20 +01:00
db: add --ignore-dbversion to override database checks.
At your own risk, of course. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
14
daemon/db.c
14
daemon/db.c
@@ -1172,9 +1172,17 @@ static void db_check_version(struct lightningd_state *dstate)
|
||||
fatal("db_check_version:step gave %s:%s",
|
||||
sqlite3_errstr(err), sqlite3_errmsg(sql));
|
||||
ver = sqlite3_column_str(stmt, 0);
|
||||
if (!streq(ver, VERSION))
|
||||
fatal("DATABASE NEEDS UPDATE. Version %s does not match %s",
|
||||
ver, VERSION);
|
||||
if (!streq(ver, VERSION)) {
|
||||
if (dstate->config.db_version_ignore)
|
||||
log_unusual(dstate->base_log,
|
||||
"DATABASE NEEDS UPDATE."
|
||||
" Version %s does not match %s",
|
||||
ver, VERSION);
|
||||
else
|
||||
fatal("DATABASE NEEDS UPDATE."
|
||||
" Version %s does not match %s",
|
||||
ver, VERSION);
|
||||
}
|
||||
}
|
||||
tal_free(ctx);
|
||||
}
|
||||
|
||||
@@ -161,6 +161,10 @@ static void config_register_opts(struct lightningd_state *dstate)
|
||||
opt_register_noarg("--disable-irc", opt_set_invbool,
|
||||
&dstate->config.use_irc,
|
||||
"Disable IRC peer discovery for routing");
|
||||
|
||||
opt_register_noarg("--ignore-dbversion", opt_set_bool,
|
||||
&dstate->config.db_version_ignore,
|
||||
"Continue despite invalid database version (DANGEROUS!)");
|
||||
}
|
||||
|
||||
static void dev_register_opts(struct lightningd_state *dstate)
|
||||
@@ -228,6 +232,9 @@ static const struct config testnet_config = {
|
||||
|
||||
/* Discover new peers using IRC */
|
||||
.use_irc = true,
|
||||
|
||||
/* Don't ignore database version */
|
||||
.db_version_ignore = false,
|
||||
};
|
||||
|
||||
/* aka. "Dude, where's my coins?" */
|
||||
@@ -289,6 +296,9 @@ static const struct config mainnet_config = {
|
||||
|
||||
/* Discover new peers using IRC */
|
||||
.use_irc = true,
|
||||
|
||||
/* Don't ignore database version */
|
||||
.db_version_ignore = false,
|
||||
};
|
||||
|
||||
static void check_config(struct lightningd_state *dstate)
|
||||
|
||||
@@ -62,6 +62,9 @@ struct config {
|
||||
|
||||
/* Whether to enable IRC peer discovery. */
|
||||
bool use_irc;
|
||||
|
||||
/* Whether to ignore database version. */
|
||||
bool db_version_ignore;
|
||||
};
|
||||
|
||||
/* Here's where the global variables hide! */
|
||||
|
||||
Reference in New Issue
Block a user