Add hash to ViewInfo

This commit is contained in:
Vinnie Falco
2015-06-30 12:46:59 -07:00
parent bf775036bc
commit ab20ca95aa
4 changed files with 12 additions and 9 deletions

View File

@@ -189,6 +189,7 @@ Ledger::Ledger (bool /* dummy */,
info_.seq = prevLedger.info_.seq + 1; info_.seq = prevLedger.info_.seq + 1;
info_.parentCloseTime = info_.parentCloseTime =
prevLedger.info_.closeTime; prevLedger.info_.closeTime;
info_.hash = prevLedger.info().hash + uint256(1);
prevLedger.updateHash (); prevLedger.updateHash ();
mParentHash = prevLedger.getHash (); mParentHash = prevLedger.getHash ();
@@ -274,7 +275,7 @@ void Ledger::updateHash()
} }
// VFALCO This has to match addRaw // VFALCO This has to match addRaw
mHash = sha512Half( info_.hash = sha512Half(
HashPrefix::ledgerMaster, HashPrefix::ledgerMaster,
std::uint32_t(info_.seq), std::uint32_t(info_.seq),
std::uint64_t(mTotCoins), std::uint64_t(mTotCoins),
@@ -464,7 +465,7 @@ Ledger::getHash()
{ {
if (! mValidHash) if (! mValidHash)
updateHash(); updateHash();
return mHash; return info_.hash;
} }
bool Ledger::saveValidatedLedger (bool current) bool Ledger::saveValidatedLedger (bool current)
@@ -516,7 +517,7 @@ bool Ledger::saveValidatedLedger (bool current)
s.add32 (HashPrefix::ledgerMaster); s.add32 (HashPrefix::ledgerMaster);
addRaw (s); addRaw (s);
getApp().getNodeStore ().store ( getApp().getNodeStore ().store (
hotLEDGER, std::move (s.modData ()), mHash); hotLEDGER, std::move (s.modData ()), info_.hash);
} }
AcceptedLedger::pointer aLedger; AcceptedLedger::pointer aLedger;
@@ -527,7 +528,7 @@ bool Ledger::saveValidatedLedger (bool current)
catch (...) catch (...)
{ {
WriteLog (lsWARNING, Ledger) << "An accepted ledger was missing nodes"; WriteLog (lsWARNING, Ledger) << "An accepted ledger was missing nodes";
getApp().getLedgerMaster().failedSave(info_.seq, mHash); getApp().getLedgerMaster().failedSave(info_.seq, info_.hash);
// Clients can now trust the database for information about this // Clients can now trust the database for information about this
// ledger sequence. // ledger sequence.
getApp().pendingSaves().erase(getLedgerSeq()); getApp().pendingSaves().erase(getLedgerSeq());
@@ -1065,10 +1066,10 @@ void Ledger::visitStateItems (std::function<void (SLE::ref)> callback) const
} }
catch (SHAMapMissingNode&) catch (SHAMapMissingNode&)
{ {
if (mHash.isNonZero ()) if (info_.hash.isNonZero ())
{ {
getApp().getInboundLedgers().acquire( getApp().getInboundLedgers().acquire(
mHash, info_.seq, InboundLedger::fcGENERIC); info_.hash, info_.seq, InboundLedger::fcGENERIC);
} }
throw; throw;
} }
@@ -1132,7 +1133,7 @@ bool Ledger::walkLedger () const
bool Ledger::assertSane () bool Ledger::assertSane ()
{ {
if (mHash.isNonZero () && if (info_.hash.isNonZero () &&
mAccountHash.isNonZero () && mAccountHash.isNonZero () &&
stateMap_ && stateMap_ &&
txMap_ && txMap_ &&

View File

@@ -443,7 +443,6 @@ private:
void deprecatedUpdateCachedFees() const; void deprecatedUpdateCachedFees() const;
// The basic Ledger structure, can be opened, closed, or synching // The basic Ledger structure, can be opened, closed, or synching
uint256 mHash; // VFALCO This could be boost::optional<uint256>
uint256 mParentHash; uint256 mParentHash;
uint256 mTransHash; uint256 mTransHash;
uint256 mAccountHash; uint256 mAccountHash;

View File

@@ -73,6 +73,9 @@ MetaView::MetaView (open_ledger_t,
info_.seq = parent.info().seq + 1; info_.seq = parent.info().seq + 1;
info_.parentCloseTime = info_.parentCloseTime =
parent.info().closeTime; parent.info().closeTime;
// Give clients a unique but
// meaningless hash for open ledgers.
info_.hash = parent.info().hash + uint256(1);
} }
MetaView::MetaView (BasicView const& base, MetaView::MetaView (BasicView const& base,

View File

@@ -76,7 +76,7 @@ struct ViewInfo
// Fields for closed ledgers // Fields for closed ledgers
// Closed means "tx set already determined" // Closed means "tx set already determined"
//uint256 hash; uint256 hash = zero;
//uint256 txHash; //uint256 txHash;
//uint256 stateHash; //uint256 stateHash;
//uint256 parentHash; //uint256 parentHash;