Skip to content

New storage api#10693

Open
ecdsa wants to merge 5 commits into
masterfrom
new_storage_api
Open

New storage api#10693
ecdsa wants to merge 5 commits into
masterfrom
new_storage_api

Conversation

@ecdsa

@ecdsa ecdsa commented Jun 7, 2026

Copy link
Copy Markdown
Member

I am marking this as ready because it is advanced enough that it could use some review.

My hope was to make the first commit pass all the tests, but that seems to be impossible. Commit 4 (types conversions) restores functionality. Note that commit 2 (perf optimization) and 3 (rename) are trivial, and they could potentially be reordered after commit 4.

There are 3 remaining design issues:

  1. should StoredDict.get() return dict/list instead of StoredList/StoredDict ?

    • pro: get() would be consistent with pop()
    • con: get() would be inconsistent with __getitem__ , which must return StoredList/StoredDict
    • pro: in order to access/create StoredDict/StoredList, we would move get_dict, get_list from wallet_db to stored_dict. This would make the returned types more explicit.
    • pro: this would simplify DB upgrades, and code in general
  2. should we remove the init_db parameter in the constructor, and use an explicit DictStorage.open() call instead?

    • probably cleaner, there is already a close() method
    • open would take the password as parameter, and behave as decrypt(). Howver, it would need to be called even for non-encrypted wallets.
  3. currently if an exception is raised during a batch write, memory and disk become inconsistent (see FIXME)

    • ideally, we should get rid of save_db, and always write to disk if we are not in a batch.
    • this would be easy if we had partial writes always enabled (not implemented yet with encrypted wallets)

@ecdsa ecdsa force-pushed the new_storage_api branch 9 times, most recently from ea2886b to 2f25568 Compare June 15, 2026 09:17
@ecdsa ecdsa force-pushed the new_storage_api branch 9 times, most recently from c3f6c61 to 44b951d Compare June 22, 2026 15:36
@ecdsa ecdsa force-pushed the new_storage_api branch 12 times, most recently from 106685f to 9938ba5 Compare June 24, 2026 09:26
@ecdsa ecdsa force-pushed the new_storage_api branch 4 times, most recently from 3257e5c to 88e66c9 Compare June 24, 2026 16:31
ecdsa added 5 commits June 24, 2026 18:56
  - WalletDB no longer inherits from JsonDB, it uses a StoredDict
  - JsonDB inherits from BaseDB
  - FileStorage is only seen by JsonDB
  - calling JSonDB constructor creates the storage

note: this commit temporarily breaks DB upgrades
this restores DB upgrades.
(DB upgrades require not converting stored classes)
Add unit test of atomicity.
Use a write batch for DB upgrades.
@ecdsa ecdsa force-pushed the new_storage_api branch from 88e66c9 to ff565a0 Compare June 24, 2026 17:07
@ecdsa ecdsa marked this pull request as ready for review June 24, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant