mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 13:35:54 +00:00
Add "ledger" command to get ledger information. Make the command
work with no parameters. Fix a bug where the ledger's account/txn hashes didn't get properly synchronized to the SHA maps. Add function to get ledger as json object.
This commit is contained in:
27
Ledger.cpp
27
Ledger.cpp
@@ -44,6 +44,11 @@ Ledger::Ledger(Ledger &prevLedger, uint64 ts) : mTimeStamp(ts),
|
||||
|
||||
void Ledger::updateHash()
|
||||
{
|
||||
if(mTransactionMap) mTransHash=mTransactionMap->getHash();
|
||||
else mTransHash=0;
|
||||
if(mAccountStateMap) mAccountHash=mAccountStateMap->getHash();
|
||||
else mAccountHash=0;
|
||||
|
||||
Serializer s(116);
|
||||
addRaw(s);
|
||||
mHash=s.getSHA512Half();
|
||||
@@ -265,7 +270,8 @@ Ledger::TransResult Ledger::hasTransaction(Transaction::pointer trans)
|
||||
|
||||
Ledger::pointer Ledger::closeLedger(uint64 timeStamp)
|
||||
{ // close this ledger, return a pointer to the next ledger
|
||||
// CAUTION: New ledger needs its SHAMap's connected to storage
|
||||
// CAUTION: New ledger needs its SHAMap's connected to storage
|
||||
updateHash();
|
||||
setClosed();
|
||||
return Ledger::pointer(new Ledger(*this, timeStamp));
|
||||
}
|
||||
@@ -408,3 +414,22 @@ Ledger::pointer Ledger::loadByHash(const uint256& ledgerHash)
|
||||
sql.append("';");
|
||||
return getSQL(sql);
|
||||
}
|
||||
|
||||
void Ledger::addJson(Json::Value& ret)
|
||||
{
|
||||
Json::Value ledger(Json::objectValue);
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
ledger["ParentHash"]=mParentHash.GetHex();
|
||||
|
||||
if(mClosed)
|
||||
{
|
||||
ledger["Hash"]=mHash.GetHex();
|
||||
ledger["TransactionHash"]=mTransHash.GetHex();
|
||||
ledger["AccountHash"]=mAccountHash.GetHex();
|
||||
ledger["Closed"]=true;
|
||||
ledger["Accepted"]=mAccepted;
|
||||
}
|
||||
else ledger["Closed"]=false;
|
||||
ret[boost::lexical_cast<std::string>(mLedgerSeq)]=ledger;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user