A WalletDatabase abstract class is created from BerkeleyDatabase and is implemented by BerkeleyDatabase. First, to get to the point that this is possible, 4 functions need to be added to BerkeleyDatabase: AddRef, RemoveRef, Open, and Close.
First the increment and decrement of mapFileUseCount is refactored into separate functions AddRef and RemoveRef.
Open is introduced as a dummy function. This will raise an exception so that it always fails.
Close is refactored from Flush. The shutdown argument in Flush is removed and instead Flush(true) is now the Close function.
Split from #18971