Batch write imported stuff in importmulti
Summary:
- Add AddWatchOnlyWithDB, AddKeyOriginWithDB, AddCScriptWithDB functions
AddWatchOnlyWithDB, AddKeyOriginWithDB, and AddCScriptWithDB add their
respective data to the wallet using the provided WalletBatch instead
of creating a new WalletBatch object every time. This allows for batching
writes to the database.
- Have WalletBatch automatically flush every 1000 updates
Since it now automatically flushes, we don't need to have
UpgradeKeyMetadata count and flush separately
- Batch writes for importmulti
When writing all of the imported data to the wallet, use a common
WalletBatch object so that batch writes are done and the writes
finish more quickly.
AddKeypoolPubkey is no longer needed so it is also removed
- Move some of ProcessImport into CWallet::Import*
This maintains encapsulation of CWallet::database in the face of
batching, e.g. allows making the WithDB methods private.
- Apply the batch treatment to CWallet::SetAddressBook via ImportScriptPubKeys
- wallet: Pass WalletBatch to CWallet::UnsetWalletFlag
This is a backport of Core PR15741
I did it all in one block even though it's quite large because intermediate commits do not work individualy.
Depends on D6385
Test Plan:
ninja all check-all
Reviewers: #bitcoin_abc, majcosta
Reviewed By: #bitcoin_abc, majcosta
Subscribers: majcosta
Differential Revision: https://reviews.bitcoinabc.org/D6387