rippled
Loading...
Searching...
No Matches
TxHistory.cpp
1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/main/Application.h>
3#include <xrpld/app/misc/DeliverMax.h>
4#include <xrpld/app/misc/Transaction.h>
5#include <xrpld/app/rdb/RelationalDatabase.h>
6#include <xrpld/rpc/Context.h>
7#include <xrpld/rpc/Role.h>
8
9#include <xrpl/protocol/ErrorCodes.h>
10#include <xrpl/protocol/RPCErr.h>
11#include <xrpl/protocol/jss.h>
12#include <xrpl/resource/Fees.h>
13
14namespace ripple {
15
16// {
17// start: <index>
18// }
21{
22 if (!context.app.config().useTxTables())
24
26
27 if (!context.params.isMember(jss::start))
29
30 unsigned int startIndex = context.params[jss::start].asUInt();
31
32 if ((startIndex > 10000) && (!isUnlimited(context.role)))
34
35 auto trans = context.app.getRelationalDatabase().getTxHistory(startIndex);
36
37 Json::Value obj;
38 Json::Value& txs = obj[jss::txs];
39 obj[jss::index] = startIndex;
40
41 for (auto const& t : trans)
42 {
43 Json::Value tx_json = t->getJson(JsonOptions::none);
45 tx_json, t->getSTransaction()->getTxnType(), context.apiVersion);
46 txs.append(tx_json);
47 }
48
49 return obj;
50}
51
52} // namespace ripple
Represents a JSON value.
Definition json_value.h:131
Value & append(Value const &value)
Append value to array at the end.
UInt asUInt() const
bool isMember(char const *key) const
Return true if the object has a member named key.
virtual Config & config()=0
virtual RelationalDatabase & getRelationalDatabase()=0
bool useTxTables() const
Definition Config.h:323
virtual std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex)=0
getTxHistory Returns the 20 most recent transactions starting from the given number.
void insertDeliverMax(Json::Value &tx_json, TxType txnType, unsigned int apiVersion)
Copy Amount field to DeliverMax field in transaction output JSON.
Definition DeliverMax.cpp:9
Charge const feeMediumBurdenRPC
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Json::Value doTxHistory(RPC::JsonContext &)
Definition TxHistory.cpp:20
@ rpcINVALID_PARAMS
Definition ErrorCodes.h:65
@ rpcNOT_ENABLED
Definition ErrorCodes.h:40
@ rpcNO_PERMISSION
Definition ErrorCodes.h:34
Json::Value rpcError(int iError)
Definition RPCErr.cpp:12
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Definition Role.cpp:106
unsigned int apiVersion
Definition Context.h:30
Resource::Charge & loadType
Definition Context.h:23
Application & app
Definition Context.h:22