[moveonly] Extract CWallet::CompactDatabase #17386

pull Empact wants to merge 1 commits into bitcoin:master from Empact:get-db-handle changing 3 files +21 −18
  1. Empact commented at 10:18 PM on November 5, 2019: member

    This removes the last use of CWallet::GetDBHandle, which is a layer violation (breaking encapsulation of CWallet::database) whose own comments call for its removal.

    After this, the only remaining external users of database is LegacyScriptPubKeyMan via CWallet::GetDatabase, extracted in #17260.

  2. refactor: Extract CWallet::CompactDatabase
    This removes the last use of CWallet::GetDBHandle, which is a layer
    violation.
    61af472ef8
  3. fanquake added the label Wallet on Nov 5, 2019
  4. in src/wallet/wallet.cpp:2398 in 61af472ef8
    2393 | +        dbh.nLastSeen = nUpdateCounter;
    2394 | +        dbh.nLastWalletUpdate = GetTime();
    2395 | +    }
    2396 | +
    2397 | +    if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
    2398 | +        if (BerkeleyBatch::PeriodicFlush(dbh)) {
    


    laanwj commented at 11:44 PM on November 5, 2019:

    I'm afraid this is still a layer violation, but the other way around :smile:

    • "Compacting" is berkeleyDB specific, other databases may not have anything similar
    • I don't think direct use of BerkeleyBatch is supposed to leak into wallet.cpp. At least, this is the first occurence.

    Empact commented at 12:41 AM on November 6, 2019:

    Yeah that makes sense. Thanks

  5. in src/wallet/walletdb.cpp:672 in 61af472ef8
     669 | @@ -670,20 +670,7 @@ void MaybeCompactWalletDB()
     670 |      }
     671 |  
     672 |      for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
    


    laanwj commented at 11:46 PM on November 5, 2019:

    So ideally this would iterate over current wallet databases, not current wallets, it's just that we don't have an iterator like that. Note that it does nothing with pwallet except get its database.

  6. Empact closed this on Nov 6, 2019

  7. MarcoFalke locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 12:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me