From 1ba0d40bb44af28aaaeb3f391d0b360fc60f5004 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 27 Apr 2014 02:42:12 -0700 Subject: [PATCH] Small Ledger cleanups and improvements: * Remove call to updateHash in LedgerConsensus::accept * Correct serialization size in updateHash * Add some comments to setImmutable and setAccepted --- src/ripple_app/consensus/LedgerConsensus.cpp | 2 -- src/ripple_app/ledger/Ledger.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ripple_app/consensus/LedgerConsensus.cpp b/src/ripple_app/consensus/LedgerConsensus.cpp index 980af937a..622579bf7 100644 --- a/src/ripple_app/consensus/LedgerConsensus.cpp +++ b/src/ripple_app/consensus/LedgerConsensus.cpp @@ -928,8 +928,6 @@ private: } newLCL->setAccepted (closeTime, mCloseResolution, closeTimeCorrect); - newLCL->updateHash (); - newLCL->setImmutable (); getApp().getLedgerMaster().storeLedger(newLCL); WriteLog (lsDEBUG, LedgerConsensus) diff --git a/src/ripple_app/ledger/Ledger.cpp b/src/ripple_app/ledger/Ledger.cpp index a7dda4a94..511c580da 100644 --- a/src/ripple_app/ledger/Ledger.cpp +++ b/src/ripple_app/ledger/Ledger.cpp @@ -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); 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 assert (mClosed && !mAccepted); mCloseTime = correctCloseTime ? roundCloseTime (closeTime, closeResolution) : closeTime; mCloseResolution = closeResolution;