Skip to content

Commit

Permalink
lightningd: clean up commando rune_counter from datastore on migration.
Browse files Browse the repository at this point in the history
Pointed out by @ShahanaFarooqui, we leave a single unused entry in the datastore,
so we should clean that up too.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jul 25, 2023
1 parent 0e5668b commit 83480a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/test_runes.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_commando_rune_migration(node_factory):
l1.daemon.wait_for_logs(['Transferring commando rune to db: '] * 2)

# datastore should be empty:
assert l1.rpc.listdatastore(['commando', 'runes']) == {'datastore': []}
assert l1.rpc.listdatastore(['commando']) == {'datastore': []}

# Should match commando results!
assert l1.rpc.showrunes() == {'runes': [{'rune':
Expand All @@ -460,7 +460,7 @@ def test_commando_blacklist_migration(node_factory):
l1.daemon.wait_for_logs(['Transferring commando blacklist to db: '] * 2)

# datastore should be empty:
assert l1.rpc.listdatastore(['commando', 'blacklist']) == {'datastore': []}
assert l1.rpc.listdatastore(['commando']) == {'datastore': []}

# Should match commando results!
assert l1.rpc.blacklistrune() == {'blacklist': [{'start': 0, 'end': 6},
Expand Down
6 changes: 6 additions & 0 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -5722,4 +5722,10 @@ void migrate_datastore_commando_runes(struct lightningd *ld, struct db *db)
db_insert_blacklist(db, &b);
}
db_datastore_remove(db, startkey);

/* Might as well clean up "rune_counter" while we're here, so
* commando datastore is completely clean. */
startkey[0] = "commando";
startkey[1] = "rune_counter";
db_datastore_remove(db, startkey);
}

0 comments on commit 83480a0

Please sign in to comment.