New ledger code.

This commit is contained in:
JoelKatz
2012-06-09 02:22:15 -07:00
parent 51ba107e2c
commit eaf511ebb6
2 changed files with 23 additions and 5 deletions

View File

@@ -336,20 +336,37 @@ void Ledger::addJson(Json::Value& ret, int options)
else ledger["Closed"] = false;
if (mCloseTime != 0)
ledger["CloseTime"] = boost::posix_time::to_simple_string(ptFromSeconds(mCloseTime));
if ((options & LEDGER_JSON_DUMP_TXNS) != 0)
bool full = (options & LEDGER_JSON_FULL) != 0;
if (full || ((options & LEDGER_JSON_DUMP_TXNS) != 0))
{
Json::Value txns(Json::arrayValue);
for (SHAMapItem::pointer item = mTransactionMap->peekFirstItem(); !!item;
item = mTransactionMap->peekNextItem(item->getTag()))
txns.append(item->getTag().GetHex());
{
if (full)
{
SerializerIterator sit(item->peekSerializer());
SerializedTransaction txn(sit);
txns.append(txn.getJson(0));
}
else txns.append(item->getTag().GetHex());
}
ledger["Transactions"] = txns;
}
if ((options & LEDGER_JSON_DUMP_STATE) != 0)
if (full || ((options & LEDGER_JSON_DUMP_STATE) != 0))
{
Json::Value state(Json::arrayValue);
for (SHAMapItem::pointer item = mAccountStateMap->peekFirstItem(); !!item;
item = mAccountStateMap->peekNextItem(item->getTag()))
state.append(item->getTag().GetHex());
{
if (full)
{
SerializerIterator sit(item->peekSerializer());
SerializedLedgerEntry sle(sit, item->getTag());
state.append(sle.getJson(0));
}
else state.append(item->getTag().GetHex());
}
ledger["AccountState"] = state;
}
ret[boost::lexical_cast<std::string>(mLedgerSeq)] = ledger;

View File

@@ -2143,12 +2143,13 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
if (command == "wallet_propose") return doWalletPropose(params);
if (command == "wallet_seed") return doWalletSeed(params);
if (command=="ledger") return doLedger(params);
//
// Obsolete or need rewrite:
//
if (command=="tx") return doTx(params);
if (command=="ledger") return doLedger(params);
return "unknown command";
}