From 3fa2028eb200a2f2c29c48356e2b0b565eb3b316 Mon Sep 17 00:00:00 2001 From: Miguel Portilla Date: Tue, 8 Dec 2015 12:10:17 -0500 Subject: [PATCH] Add expiration to account_offers (RIPD-1049) --- src/ripple/protocol/JsonFields.h | 1 + src/ripple/rpc/handlers/AccountOffers.cpp | 32 +++++++++++------------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/ripple/protocol/JsonFields.h b/src/ripple/protocol/JsonFields.h index bd4afb2a4..9623a8356 100644 --- a/src/ripple/protocol/JsonFields.h +++ b/src/ripple/protocol/JsonFields.h @@ -150,6 +150,7 @@ JSS ( error_exception ); // out: Submit JSS ( error_message ); // out: error JSS ( expand ); // in: handler/Ledger JSS ( expected_ledger_size ); // out: TxQ +JSS ( expiration ); // out: AccountOffers JSS ( fail_hard ); // in: Sign, Submit JSS ( failed ); // out: InboundLedger JSS ( feature ); // in: Feature diff --git a/src/ripple/rpc/handlers/AccountOffers.cpp b/src/ripple/rpc/handlers/AccountOffers.cpp index e7c134c69..ab7340dfc 100644 --- a/src/ripple/rpc/handlers/AccountOffers.cpp +++ b/src/ripple/rpc/handlers/AccountOffers.cpp @@ -44,6 +44,8 @@ void appendOfferJson (std::shared_ptr const& offer, obj[jss::seq] = offer->getFieldU32 (sfSequence); obj[jss::flags] = offer->getFieldU32 (sfFlags); obj[jss::quality] = dirRate.getText (); + if (offer->isFieldPresent(sfExpiration)) + obj[jss::expiration] = offer->getFieldU32(sfExpiration); }; // { @@ -120,22 +122,20 @@ Json::Value doAccountOffers (RPC::Context& context) offers.reserve (++reserve); } - { - if (! forEachItemAfter(*ledger, accountID, - startAfter, startHint, reserve, - [&offers](std::shared_ptr const& offer) - { - if (offer->getType () == ltOFFER) - { - offers.emplace_back (offer); - return true; - } - - return false; - })) + if (! forEachItemAfter(*ledger, accountID, + startAfter, startHint, reserve, + [&offers](std::shared_ptr const& offer) { - return rpcError (rpcINVALID_PARAMS); - } + if (offer->getType () == ltOFFER) + { + offers.emplace_back (offer); + return true; + } + + return false; + })) + { + return rpcError (rpcINVALID_PARAMS); } if (offers.size () == reserve) @@ -147,9 +147,7 @@ Json::Value doAccountOffers (RPC::Context& context) } for (auto const& offer : offers) - { appendOfferJson(offer, jsonOffers); - } context.loadType = Resource::feeMediumBurdenRPC; return result;