Add expiration to account_offers (RIPD-1049)

This commit is contained in:
Miguel Portilla
2015-12-08 12:10:17 -05:00
committed by Nik Bougalis
parent d5c14755ce
commit 3fa2028eb2
2 changed files with 16 additions and 17 deletions

View File

@@ -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

View File

@@ -44,6 +44,8 @@ void appendOfferJson (std::shared_ptr<SLE const> 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<SLE const> 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<SLE const> 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;