From aa2503081ef819358440540a259852f84e6e9e6c Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 6 Mar 2013 03:52:56 -0800 Subject: [PATCH] Make this code easier to debug. --- src/cpp/ripple/AccountItems.cpp | 8 ++++++++ src/cpp/ripple/AccountItems.h | 2 ++ src/cpp/ripple/Offer.cpp | 9 +++++++++ src/cpp/ripple/Offer.h | 1 + src/cpp/ripple/RippleState.cpp | 8 ++++++++ src/cpp/ripple/RippleState.h | 1 + 6 files changed, 29 insertions(+) diff --git a/src/cpp/ripple/AccountItems.cpp b/src/cpp/ripple/AccountItems.cpp index 1cca67ee9..cbad2cb2e 100644 --- a/src/cpp/ripple/AccountItems.cpp +++ b/src/cpp/ripple/AccountItems.cpp @@ -49,4 +49,12 @@ void AccountItems::fillItems(const uint160& accountID, Ledger::ref ledger) } } +Json::Value AccountItems::getJson(int v) +{ + Json::Value ret(Json::arrayValue); + BOOST_FOREACH(AccountItem::ref ai, mItems) + ret.append(ai->getJson(v)); + return ret; +} + // vim:ts=4 diff --git a/src/cpp/ripple/AccountItems.h b/src/cpp/ripple/AccountItems.h index 8b2cd0213..eea600a76 100644 --- a/src/cpp/ripple/AccountItems.h +++ b/src/cpp/ripple/AccountItems.h @@ -20,6 +20,7 @@ public: virtual ~AccountItem() { ; } virtual AccountItem::pointer makeItem(const uint160& accountID, SerializedLedgerEntry::ref ledgerEntry)=0; virtual LedgerEntryType getType()=0; + virtual Json::Value getJson(int)=0; SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; } const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; } @@ -41,6 +42,7 @@ public: AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType); std::vector& getItems() { return(mItems); } + Json::Value getJson(int); }; #endif diff --git a/src/cpp/ripple/Offer.cpp b/src/cpp/ripple/Offer.cpp index 126f6801b..aa7296ec0 100644 --- a/src/cpp/ripple/Offer.cpp +++ b/src/cpp/ripple/Offer.cpp @@ -15,4 +15,13 @@ Offer::Offer(SerializedLedgerEntry::pointer ledgerEntry) : AccountItem(ledgerEnt mSeq = mLedgerEntry->getFieldU32(sfSequence); } +Json::Value Offer::getJson(int) +{ + Json::Value ret(Json::objectValue); + ret["account"] = mAccount.humanAccountID(); + ret["taker_gets"] = getTakerGets().getFullText(); + ret["taker_pays"] = getTakerPays().getFullText(); + return ret; +} + // vim:ts=4 diff --git a/src/cpp/ripple/Offer.h b/src/cpp/ripple/Offer.h index 476575237..cdb9dd8e8 100644 --- a/src/cpp/ripple/Offer.h +++ b/src/cpp/ripple/Offer.h @@ -19,6 +19,7 @@ public: STAmount getTakerGets(){ return(mTakerGets); } RippleAddress getAccount(){ return(mAccount); } int getSeq(){ return(mSeq); } + Json::Value getJson(int); }; diff --git a/src/cpp/ripple/RippleState.cpp b/src/cpp/ripple/RippleState.cpp index 65facb7f1..bf542a9ae 100644 --- a/src/cpp/ripple/RippleState.cpp +++ b/src/cpp/ripple/RippleState.cpp @@ -44,4 +44,12 @@ void RippleState::setViewAccount(const uint160& accountID) } } +Json::Value RippleState::getJson(int) +{ + Json::Value ret(Json::objectValue); + ret["low_id"] = mLowID.GetHex(); + ret["high_id"] = mHighID.GetHex(); + return ret; +} + // vim:ts=4 diff --git a/src/cpp/ripple/RippleState.h b/src/cpp/ripple/RippleState.h index 15a265777..5685d8162 100644 --- a/src/cpp/ripple/RippleState.h +++ b/src/cpp/ripple/RippleState.h @@ -63,6 +63,7 @@ public: SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; } const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; } SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; } + Json::Value getJson(int); std::vector getRaw() const; };