mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
wallet: only log broken if we have duplicate scids in channels.
This was reported, but the channel was closed. So however we ended up with a duplicate, we're no *worse* off than we were before migration? Fixes: #5760 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
37590eeeb2
commit
e778ebb9af
15
wallet/db.c
15
wallet/db.c
@ -1486,6 +1486,7 @@ static void migrate_channels_scids_as_integers(struct lightningd *ld,
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
char **scids = tal_arr(tmpctx, char *, 0);
|
||||
size_t changes;
|
||||
|
||||
stmt = db_prepare_v2(db, SQL("SELECT short_channel_id FROM channels"));
|
||||
db_query_prepared(stmt);
|
||||
@ -1497,6 +1498,7 @@ static void migrate_channels_scids_as_integers(struct lightningd *ld,
|
||||
}
|
||||
tal_free(stmt);
|
||||
|
||||
changes = 0;
|
||||
for (size_t i = 0; i < tal_count(scids); i++) {
|
||||
struct short_channel_id scid;
|
||||
if (!short_channel_id_from_str(scids[i], strlen(scids[i]), &scid))
|
||||
@ -1509,12 +1511,21 @@ static void migrate_channels_scids_as_integers(struct lightningd *ld,
|
||||
db_bind_scid(stmt, 0, &scid);
|
||||
db_bind_text(stmt, 1, scids[i]);
|
||||
db_exec_prepared_v2(stmt);
|
||||
|
||||
/* This was reported to happen with an (old, closed) channel: that we'd have
|
||||
* more than one change here! That's weird, but just log about it. */
|
||||
if (db_count_changes(stmt) != 1)
|
||||
db_fatal("Converting channels.short_channel_id '%s' gave %zu changes != 1?",
|
||||
scids[i], db_count_changes(stmt));
|
||||
log_broken(ld->log,
|
||||
"migrate_channels_scids_as_integers: converting channels.short_channel_id '%s' gave %zu changes != 1!",
|
||||
scids[i], db_count_changes(stmt));
|
||||
changes += db_count_changes(stmt);
|
||||
tal_free(stmt);
|
||||
}
|
||||
|
||||
if (changes != tal_count(scids))
|
||||
fatal("migrate_channels_scids_as_integers: only converted %zu of %zu scids!",
|
||||
changes, tal_count(scids));
|
||||
|
||||
/* FIXME: We cannot use ->delete_columns to remove
|
||||
* short_channel_id, as other tables reference the channels
|
||||
* (and sqlite3 has them referencing a now-deleted table!).
|
||||
|
Loading…
Reference in New Issue
Block a user