Page MenuHomePhabricator

Batch write imported stuff in importmulti
ClosedPublic

Authored by deadalnix on Jun 5 2020, 17:06.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABC8792ff7cef71: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

This revision is now accepted and ready to land.Jun 5 2020, 17:43