Cleanups. Extra asserts.

This commit is contained in:
JoelKatz
2012-10-15 03:50:14 -07:00
parent 65395ea971
commit 83a2b0d884
2 changed files with 21 additions and 4 deletions

View File

@@ -336,8 +336,9 @@ bool Ledger::unitTest()
uint256 Ledger::getHash()
{
if(!mValidHash) updateHash();
return(mHash);
if (!mValidHash)
updateHash();
return mHash;
}
void Ledger::saveAcceptedLedger()
@@ -351,6 +352,15 @@ void Ledger::saveAcceptedLedger()
"(LedgerHash,LedgerSeq,PrevHash,TotalCoins,ClosingTime,PrevClosingTime,CloseTimeRes,CloseFlags,"
"AccountSetHash,TransSetHash) VALUES ('%s','%u','%s','%s','%u','%u','%d','%u','%s','%s');");
if (!getAccountHash().isNonZero())
{
cLog(lsFATAL) << "AH is zero: " << getJson(0);
assert(false);
}
assert (getAccountHash() == mAccountStateMap->getHash());
assert (getTransHash() == mTransactionMap->getHash());
{
ScopedLock sl(theApp->getLedgerDB()->getDBLock());
if (SQL_EXISTS(theApp->getLedgerDB()->getDB(), boost::str(ledgerExists % mLedgerSeq)))
@@ -477,6 +487,7 @@ Ledger::pointer Ledger::getSQL(const std::string& sql)
assert(false);
return Ledger::pointer();
}
Log(lsDEBUG) << "Loaded ledger: " << ledgerHash;
return ret;
}
@@ -497,6 +508,11 @@ Ledger::pointer Ledger::loadByHash(const uint256& ledgerHash)
}
void Ledger::addJson(Json::Value& ret, int options)
{
ret["ledger"] = getJson(options);
}
Json::Value Ledger::getJson(int options)
{
Json::Value ledger(Json::objectValue);
@@ -582,8 +598,8 @@ void Ledger::addJson(Json::Value& ret, int options)
}
ledger["accountState"] = state;
}
ledger["seqNum"]=boost::lexical_cast<std::string>(mLedgerSeq);
ret["ledger"] = ledger;
ledger["seqNum"] = boost::lexical_cast<std::string>(mLedgerSeq);
return ledger;
}
void Ledger::setAcquiring(void)

View File

@@ -278,6 +278,7 @@ public:
SLE::pointer getRippleState(const uint160& uiA, const uint160& uiB, const uint160& uCurrency)
{ return getRippleState(getRippleStateIndex(NewcoinAddress::createAccountID(uiA), NewcoinAddress::createAccountID(uiB), uCurrency)); }
Json::Value getJson(int options);
void addJson(Json::Value&, int options);
bool walkLedger();