Skip to content

Conversation

jgarzik
Copy link
Contributor

@jgarzik jgarzik commented May 13, 2012

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.

@laanwj
Copy link
Member

laanwj commented May 13, 2012

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

@sipa
Copy link
Member

sipa commented May 13, 2012

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.

@jgarzik
Copy link
Contributor Author

jgarzik commented May 14, 2012

Rebased on top of #1293 (BDB environment encapsulation)

@jgarzik
Copy link
Contributor Author

jgarzik commented May 14, 2012

Updated to do cross-db transactions.

@Diapolo
Copy link

Diapolo commented May 14, 2012

This includes #1293 now?

@jgarzik
Copy link
Contributor Author

jgarzik commented May 14, 2012

Yes, see comment above.

Jeff Garzik and others added 6 commits May 14, 2012 12:21
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.
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.
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.
@jgarzik
Copy link
Contributor Author

jgarzik commented May 14, 2012

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

@jgarzik
Copy link
Contributor Author

jgarzik commented May 14, 2012

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

@jgarzik jgarzik closed this May 14, 2012
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Jan 22, 2019
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request May 6, 2020
… chainparams

c5a8adb [Core][Cleanup] Add IsRegTestNet() function in chainparams (random-zebra)

Pull request description:

  This removes many explicit checks `Params().NetworkID() != CBaseChainParams::REGTEST` / `Params().NetworkID() == CBaseChainParams::REGTEST` making the code more readable.

ACKs for top commit:
  Fuzzbawls:
    ACK c5a8adb

Tree-SHA512: ce6373be461c1db87cd48e4046c0c7429a57253a9fbd52d649f65e7ddb0385d0cf87b81f0538b97521f663f8ad79fbcc68f5e2bdbd9ca339ae8599d3d1cc38a6
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants