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).
Change hardcoded character constants to descriptive named constants for db keys #5707
pull Earlz wants to merge 1 commits into bitcoin:master from Earlz:master changing 1 files +32 −21-
Earlz commented at 3:31 PM on January 25, 2015: contributor
-
sipa commented at 3:36 PM on January 25, 2015: member
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.
-
change hardcoded character constants to a set of descriptive named constants for database keys 14d023f1ae
- Earlz force-pushed on Jan 25, 2015
-
Earlz commented at 3:59 PM on January 25, 2015: contributor
Alrght, I changed it to use
static const charand rebased it into the commit - Earlz renamed this:
Change hardcoded character constants to a descriptive enum for db keys
Change hardcoded character constants to descriptive constants for db keys
on Jan 25, 2015 - Earlz renamed this:
Change hardcoded character constants to descriptive constants for db keys
Change hardcoded character constants to descriptive named constants for db keys
on Jan 25, 2015 - laanwj added the label Improvement on Jan 26, 2015
-
laanwj commented at 10:14 AM on January 26, 2015: member
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 merged this on Jan 31, 2015
- laanwj closed this on Jan 31, 2015
- laanwj referenced this in commit 6af674ecdc on Jan 31, 2015
- random-zebra referenced this in commit 73d26f20e9 on May 27, 2020
- DrahtBot locked this on Sep 8, 2021