Page MenuHomePhabricator

walletdb: Refactor DatabaseBatch abstract class from BerkeleyBatch
ClosedPublic

Authored by PiRK on Sep 1 2021, 08:22.

Details

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

Diff Detail

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