From eaf511ebb605108707f3d1f998832a333685eddd Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 9 Jun 2012 02:22:15 -0700 Subject: [PATCH] New ledger code. --- src/Ledger.cpp | 25 +++++++++++++++++++++---- src/RPCServer.cpp | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Ledger.cpp b/src/Ledger.cpp index 440fb393a2..a77b0e649c 100644 --- a/src/Ledger.cpp +++ b/src/Ledger.cpp @@ -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(mLedgerSeq)] = ledger; diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index f325ce6a81..6ba9ad38d4 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -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"; }