HomePhabricator

walletdb: Refactor DatabaseBatch abstract class from BerkeleyBatch

Description

walletdb: Refactor DatabaseBatch abstract class from BerkeleyBatch

Summary:

In order to support alternative database systems, we need to have a generic Batch class. This PR adds a DatabaseBatch abstract class which is implemented by BerkeleyBatch. DatabaseBatch is now the class that is used by WalletBatch to interact with the database. To be able to get the correct type of DatabaseBatch, BerkeleyDatabase now has a MakeBatch function which returns a newly constructed std::unique_ptr<DatabaseBatch>. For BerkeleyDatabase, that will be std::unique_ptr<BerkeleyBatch>.

The Read, Write, Erase, and Exists template functions are moved from BerkeleyBatch.

This is a backport of core#19325 [1/2]
https://github.com/bitcoin/bitcoin/pull/19325/commits/eac9200814fa01da6522625be01dded730b26751

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10002

Details

Provenance
Andrew Chow <achow101-github@achow101.com>Authored on Jun 18 2020, 20:15
PiRKCommitted on Sep 1 2021, 09:10
PiRKPushed on Sep 1 2021, 09:10
Reviewer
Restricted Project
Differential Revision
D10002: walletdb: Refactor DatabaseBatch abstract class from BerkeleyBatch
Parents
rABCabd24602e018: test: improve mempool_updatefromblock efficiency by using getmempoolentry for…
Branches
Unknown
Tags
Unknown