-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small Ledger cleanups and improvements: #330
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,8 @@ Ledger::~Ledger () | |
|
||
void Ledger::setImmutable () | ||
{ | ||
// Updates the hash and marks the ledger and its maps immutable | ||
|
||
updateHash (); | ||
mImmutable = true; | ||
|
||
|
@@ -245,8 +247,8 @@ void Ledger::updateHash () | |
mAccountHash.zero (); | ||
} | ||
|
||
// VFALCO TODO Fix this hard coded magic number 118 | ||
Serializer s (118); | ||
// VFALCO TODO Fix this hard coded magic number 122 | ||
Serializer s (122); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to ask another question :-) Why is this 122 rather than the 128, used here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would assume one actually computed it and one just rounded up. We should have constants for the length of a serialized ledger without the hash prefix and the length with a hash prefix. Without a hash prefix, a ledger header is 118 bytes. With one, it's 122. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this question speaks to the need to have sensible symbolic constant names; it's ironic that we changed the magic number inside the comment instead of actually addressing the issue pointed out by the comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to come up with a sensible way to do it and couldn't without devoting more time to it than it seemed worth. |
||
s.add32 (HashPrefix::ledgerMaster); | ||
addRaw (s); | ||
mHash = s.getSHA512Half (); | ||
|
@@ -296,6 +298,7 @@ void Ledger::addRaw (Serializer& s) const | |
void Ledger::setAccepted (std::uint32_t closeTime, int closeResolution, bool correctCloseTime) | ||
{ | ||
// used when we witnessed the consensus | ||
// Rounds the close time, updates the hash, and sets the ledger accepted and immutable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny quibble - could I get you to put a period at the end of the sentence, and/or change it to "sets the ledger to be"? I had (for some reason) difficulty parsing this sentence the first few times and thought you'd missed a second line. |
||
assert (mClosed && !mAccepted); | ||
mCloseTime = correctCloseTime ? roundCloseTime (closeTime, closeResolution) : closeTime; | ||
mCloseResolution = closeResolution; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not extract this as a constant, perhaps even bring it into the system tuning constants?