Move hash->CBlockIndex BDB into its own database, blkhash.dat #1282

pull jgarzik wants to merge 7 commits into bitcoin:master from jgarzik:blockindex changing 8 files +287 −213
  1. jgarzik commented at 7:15 AM on May 13, 2012: contributor

    blkindex.dat stores all kinds of data, and as such, each key is overloaded to form a namespace. All keys beginning with "blockindex" form the hash->CBlockIndex data that is loaded into mapBlockIndex.

    This change moves mapBlockIndex data to its own database, custom tailored for the sort of data we wish to store:

    • BDB type changed from btree to hash
    • key is uint256 hash, with no prefixes

    Usage is cleaner, and uses slightly less CPU and disk space than the previous solution.

    COMPATIBILITY STATUS: A new block chain must be downloaded, or at least reindexed. As such, may want to delay this change, if other major database changes are planned.

    MERGE STATUS: Ready for review and comment, but not ready for immediate upstreaming.

  2. laanwj commented at 7:47 AM on May 13, 2012: member

    Good idea. It's bad form to put different stuffs into one database table.

  3. sipa commented at 9:33 AM on May 13, 2012: member

    Not sure whether an entirely separate file is better, or just a separate database within the same file (which bdb also supports). You'd need to implement cross-db transaction in the glue layer anyway before this is safe.

  4. Always check return values of TxnBegin() and TxnCommit() 0fb78eae34
  5. jgarzik commented at 5:23 AM on May 14, 2012: contributor

    Rebased on top of #1293 (BDB environment encapsulation)

  6. jgarzik commented at 5:54 AM on May 14, 2012: contributor

    Updated to do cross-db transactions.

  7. Diapolo commented at 6:03 AM on May 14, 2012: none

    This includes #1293 now?

  8. jgarzik commented at 6:25 AM on May 14, 2012: contributor

    Yes, see comment above.

  9. Reorganize(): remove spurious TxnAbort()
    If Reorganize() fails, then its caller, CBlock::SetBestChain(),
    will call TxnAbort().
    
    Redundant TxnAbort() calls are harmless.  The second will return an
    error return value, with no other side effects.  TxnAbort() return
    values are generally never checked.  The impact is nil.
    060921932f
  10. Merge branch 'extra-abort' into dbenv e19963d5ba
  11. Encapsulate BDB environment inside new CDBEnv class
    Cleans up and organizes several scattered functions and variables related to
    the BDB env.  Class CDBInit() existed to provide a
    guaranteed-via-C++-destructor cleanup of the db environment.
    
    A formal CDBEnv class provides all of this inside a single wrapper.
    1e3624093d
  12. Create CDBEnv::TxnBegin(), and use it in CDB::TxnBegin() accb0268e2
  13. Remove unused nested BDB transaction support c7ab7e596e
  14. Move hash->CBlockIndex BDB into its own database, blkhash.dat
    blkindex.dat stores all kinds of data, and as such, each key is overloaded to
    form a namespace.  All keys beginning with "blockindex" form the
    hash->CBlockIndex data that is loaded into mapBlockIndex.
    
    This change moves mapBlockIndex data to its own database, custom tailored for
    the sort of data we wish to store:
    
    - BDB type changed from btree to hash
    - key is uint256 hash, with no prefixes
    
    Usage is cleaner, and uses slightly less CPU and disk space than the previous
    solution.
    ccb0a0d128
  15. jgarzik commented at 4:56 PM on May 14, 2012: contributor

    DEPENDENCY UPDATE: #1295, #1300, and #1293, in that order

  16. jgarzik commented at 6:10 PM on May 14, 2012: contributor

    Closing -- about to reopen a similar but revised pull req.

  17. jgarzik closed this on May 14, 2012

  18. lateminer referenced this in commit 1e4f5a64e9 on Jan 22, 2019
  19. lateminer referenced this in commit 76f29fccf3 on May 6, 2020
  20. DrahtBot locked this on Sep 8, 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-20 00:16 UTC

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