wallet: remove outdated `pszSkip` arg of database `Rewrite` func #32990

pull rkrux wants to merge 1 commits into bitcoin:master from rkrux:walletdb-deadcode changing 6 files +8 −8
  1. rkrux commented at 9:04 AM on July 16, 2025: contributor

    This argument might have been used in the legacy wallets, but I don't see any implementation using this argument in the SQLite wallets. Removing it cleans up the code a bit.

  2. wallet: remove outdated `pszSkip` arg of database `Rewrite` func
    This argument might have been used in the legacy wallets, but I don't
    see any implementation using this argument in the SQLite wallets.
    Removing it cleans up the code a bit.
    2dfeb6668c
  3. DrahtBot added the label Wallet on Jul 16, 2025
  4. DrahtBot commented at 9:04 AM on July 16, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32990.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK brunoerg, achow101

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33034 (wallet: Store transactions in a separate sqlite table by achow101)
    • #33032 (wallet, test: Replace MockableDatabase with in-memory SQLiteDatabase by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. rkrux commented at 9:12 AM on July 16, 2025: contributor

    I noted this while reviewing #28333.

  6. brunoerg approved
  7. brunoerg commented at 8:08 PM on July 17, 2025: contributor

    code review ACK 2dfeb6668cb2e98e3dccf946af084e8a08e1fab5

    I verified that this arg was used only by the legacy wallet. At 2dfeb6668cb2e98e3dccf946af084e8a08e1fab5 (from the PR that added sqlite), this arg was used in the following function from BerkeleyDatabase (which obviously doesn't exist anymore):

    bool BerkeleyDatabase::Rewrite(const char* pszSkip)
    {
        while (true) {
            {
                LOCK(cs_db);
                if (m_refcount <= 0) {
                    // Flush log data to the dat file
                    env->CloseDb(strFile);
                    env->CheckpointLSN(strFile);
                    m_refcount = -1;
    
                    bool fSuccess = true;
                    LogPrintf("BerkeleyBatch::Rewrite: Rewriting %s...\n", strFile);
                    std::string strFileRes = strFile + ".rewrite";
                    { // surround usage of db with extra {}
                        BerkeleyBatch db(*this, true);
                        std::unique_ptr<Db> pdbCopy = MakeUnique<Db>(env->dbenv.get(), 0);
    
                        int ret = pdbCopy->open(nullptr,               // Txn pointer
                                                strFileRes.c_str(), // Filename
                                                "main",             // Logical db name
                                                DB_BTREE,           // Database type
                                                DB_CREATE,          // Flags
                                                0);
                        if (ret > 0) {
                            LogPrintf("BerkeleyBatch::Rewrite: Can't create database file %s\n", strFileRes);
                            fSuccess = false;
                        }
    
                        if (db.StartCursor()) {
                            while (fSuccess) {
                                CDataStream ssKey(SER_DISK, CLIENT_VERSION);
                                CDataStream ssValue(SER_DISK, CLIENT_VERSION);
                                bool complete;
                                bool ret1 = db.ReadAtCursor(ssKey, ssValue, complete);
                                if (complete) {
                                    break;
                                } else if (!ret1) {
                                    fSuccess = false;
                                    break;
                                }
                                if (pszSkip &&
                                    strncmp(ssKey.data(), pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
                                    continue;
                                if (strncmp(ssKey.data(), "\x07version", 8) == 0) {
                                    // Update version:
                                    ssValue.clear();
                                    ssValue << CLIENT_VERSION;
                                }
                                Dbt datKey(ssKey.data(), ssKey.size());
                                Dbt datValue(ssValue.data(), ssValue.size());
                                int ret2 = pdbCopy->put(nullptr, &datKey, &datValue, DB_NOOVERWRITE);
                                if (ret2 > 0)
                                    fSuccess = false;
                            }
                            db.CloseCursor();
                        }
                        if (fSuccess) {
                            db.Close();
                            env->CloseDb(strFile);
                            if (pdbCopy->close(0))
                                fSuccess = false;
                        } else {
                            pdbCopy->close(0);
                        }
                    }
                    if (fSuccess) {
                        Db dbA(env->dbenv.get(), 0);
                        if (dbA.remove(strFile.c_str(), nullptr, 0))
                            fSuccess = false;
                        Db dbB(env->dbenv.get(), 0);
                        if (dbB.rename(strFileRes.c_str(), nullptr, strFile.c_str(), 0))
                            fSuccess = false;
                    }
                    if (!fSuccess)
                        LogPrintf("BerkeleyBatch::Rewrite: Failed to rewrite database file %s\n", strFileRes);
                    return fSuccess;
                }
            }
            UninterruptibleSleep(std::chrono::milliseconds{100});
        }
    }
    
  8. achow101 commented at 11:32 PM on July 22, 2025: member

    ACK 2dfeb6668cb2e98e3dccf946af084e8a08e1fab5

  9. achow101 merged this on Jul 22, 2025
  10. achow101 closed this on Jul 22, 2025

  11. sedited referenced this in commit 02ded863ba on Jul 28, 2025
  12. sedited referenced this in commit 52d7f32bd6 on Jul 28, 2025
  13. alexanderwiederin referenced this in commit 28fe919bf7 on Aug 6, 2025
  14. sedited referenced this in commit b98d982d79 on Aug 7, 2025
  15. alexanderwiederin referenced this in commit 4152176d02 on Aug 8, 2025
  16. alexanderwiederin referenced this in commit 9ef94c31db on Aug 8, 2025
  17. stringintech referenced this in commit 71275a1b5e on Aug 17, 2025
  18. yuvicc referenced this in commit 22f55cf11d on Aug 26, 2025
  19. bug-castercv502 referenced this in commit 4aa5572aea on Sep 28, 2025
  20. stickies-v referenced this in commit a19c56cd7c on Nov 4, 2025
  21. Kino1994 referenced this in commit 3b620f3d04 on Jun 28, 2026
  22. BigcoinBGC referenced this in commit 680842add8 on Jun 30, 2026
  23. bitcoin locked this on Jul 30, 2026

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-08-01 07:51 UTC

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