mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
db: Added DB migrations to get the correct sync height
The no-rescan change requires us to rescan one last time from the first_blocknum of our channels (if we have any). The migrations just drop blocks that are higher, then insert a dummy with the first_blocknum, and then clean up after us. If we don't have any channels we don't go back at all. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
ac9e5581c8
commit
89ff46f1e6
1 changed files with 10 additions and 0 deletions
10
wallet/db.c
10
wallet/db.c
|
@ -318,6 +318,16 @@ char *dbmigrations[] = {
|
|||
", blockheight INTEGER REFERENCES blocks(height) ON DELETE CASCADE"
|
||||
", PRIMARY KEY(id)"
|
||||
");",
|
||||
/* -- Set the correct rescan height for PR #1398 -- */
|
||||
/* Delete blocks that are higher than our initial scan point, this is a
|
||||
* no-op if we don't have a channel. */
|
||||
"DELETE FROM blocks WHERE height > (SELECT MIN(first_blocknum) FROM channels);",
|
||||
/* Now make sure we have the lower bound block with the first_blocknum
|
||||
* height. This may introduce a block with NULL height if we didn't have any
|
||||
* blocks, remove that in the next. */
|
||||
"INSERT OR IGNORE INTO blocks (height) VALUES ((SELECT MIN(first_blocknum) FROM channels));",
|
||||
"DELETE FROM blocks WHERE height IS NULL;",
|
||||
/* -- End of PR #1398 -- */
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue