Skip to content

Conversation

Earlz
Copy link
Contributor

@Earlz Earlz commented Jan 25, 2015

This change makes it so that all the magical constants used as database keys like 'b' are actually self-describing. I tried to make it obvious when a key is only suppose to have 1 value in the database (opposed to many).

@sipa
Copy link
Member

sipa commented Jan 25, 2015

This changes the prefix bytes into prefix ints. Ideally you'd mark the enum as char, but that's not valid C++98 (and we can't use C++11 due to compatibility reasons yet), so for now you'll have to stick with a list of constants rather than making it an enum.

@Earlz
Copy link
Contributor Author

Earlz commented Jan 25, 2015

Alrght, I changed it to use static const char and rebased it into the commit

@Earlz Earlz changed the title Change hardcoded character constants to a descriptive enum for db keys Change hardcoded character constants to descriptive constants for db keys Jan 25, 2015
@Earlz Earlz changed the title Change hardcoded character constants to descriptive constants for db keys Change hardcoded character constants to descriptive named constants for db keys Jan 25, 2015
@laanwj
Copy link
Member

laanwj commented Jan 26, 2015

I expected this to result in the same binary, but it doesn't. What appears to happen is that in 40e96a3 it puts the character in a local buffer on the stack, whereas in 14d023f it uses the address of the constant. This makes sense as it passes a reference (pointer).

In any case, I did a verification in which I replaced the constants with #defines, and that one matched.

I also did rudimentary testing to make sure this doesn't result in a different on-disk format. So ACK.

@laanwj laanwj merged commit 14d023f into bitcoin:master Jan 31, 2015
laanwj added a commit that referenced this pull request Jan 31, 2015
14d023f change hardcoded character constants to a set of descriptive named constants for database keys (Earlz)
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request May 27, 2020
82f9088 Refactor: Remove using namespace <xxx> from /dbwrapper_tests (random-zebra)
6db0b37 rpc: make `gettxoutsettinfo` run lock-free (random-zebra)
f009cf4 Do not shadow members in dbwrapper (random-zebra)
b7e540c dbwrapper: Move `HandleError` to `dbwrapper_private` (random-zebra)
43004d0 leveldbwrapper file rename to dbwrapper.* (random-zebra)
c882dd9 leveldbwrapper symbol rename: Remove "Level" from class, etc. names (random-zebra)
f6496da leveldbwrapper: Remove unused .Prev(), .SeekToLast() methods (random-zebra)
cacf3c2 Fix chainstate serialized_size computation (random-zebra)
a2a3d33 Add tests for CLevelDBBatch, CLevelDBIterator (random-zebra)
94150ac Encapsulate CLevelDB iterators cleanly (random-zebra)
21df7cc [DB] Refactor leveldbwrapper (random-zebra)
2251db3 change hardcoded character constants to a set of descriptive named co… (random-zebra)

Pull request description:

  This backports a series of updates and cleanups to the LevelDB wrapper from:

  - bitcoin#5707
  - bitcoin#6650 [`*`]
  - bitcoin#6777 [`*`]
  - bitcoin#6865
  - bitcoin#6873
  - bitcoin#7927 [`*`]
  - bitcoin#8467
  - bitcoin#6290
  - bitcoin#9281

  PIVX-specific edits were required to keep the sporks and zerocoin databases in line.

  [`*`] NOTE: excluding the obfuscation of databases by xoring data, as we might not want this feature (e.g. as zcash/zcash#2598). Otherwise it can be discussed, and added, with a separate PR.

ACKs for top commit:
  furszy:
    Re ACK 82f9088 .
  Fuzzbawls:
    ACK 82f9088

Tree-SHA512: 1e4a75621d2ec2eb68e01523d15321d1d2176b81aac0525617852899ab38c9b4980daecb9056d054e7961fc758a22143edf914c40d1819144a394f2869a8ad57
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants