BerkeleyBatch
and BerkeleyDatabase
are kind of messy. The goal of this is to clean up them up so that they are logically separated.
BerkeleyBatch
currently handles the creation of the BerkeleyDatabase
’s Db
handle. This is instead moved into BerkeleyDatabase
and is called by BerkeleyBatch
.
Instead of having BerkeleyEnvironment
track each database’s usage, have BerkeleyDatabase
track this usage itself with the m_refcount
variable that is present in WalletDatabase
.
Lastly, instead of having each BerkeleyEnvironment
store the fileids of the databases open in it, have a global g_fileids
to track those fileids. We were already checking fileid uniqueness globally (by checking the fileids in every environment when opening a database) so it’s cleaner to do this with a global variable.
All of these changes allow us to make BerkeleyBatch
and BerkeleyDatabase
no longer be friend classes.
The diff of this PR is currently the same as in ##18971
Requires #19334