20 #include <ripple/app/ledger/LedgerToJson.h>
21 #include <ripple/ledger/ReadView.h>
22 #include <ripple/protocol/ErrorCodes.h>
23 #include <ripple/protocol/LedgerFormats.h>
24 #include <ripple/protocol/jss.h>
25 #include <ripple/rpc/Context.h>
26 #include <ripple/rpc/GRPCHandlers.h>
27 #include <ripple/rpc/Role.h>
28 #include <ripple/rpc/impl/RPCHelpers.h>
29 #include <ripple/rpc/impl/Tuning.h>
48 auto const& params = context.
params;
54 bool const isMarker = params.isMember(jss::marker);
63 bool const isBinary = params[jss::binary].asBool();
66 if (params.isMember(jss::limit))
72 limit = jLimit.
asInt();
76 if ((limit < 0) || ((limit > maxLimit) && (!
isUnlimited(context.
role))))
80 jvResult[jss::ledger_index] = lpLedger->
info().
seq;
86 *lpLedger, &context, isBinary ? LedgerFill::Options::binary : 0));
93 rpcStatus.inject(jvResult);
114 if (type ==
ltANY || sle->getType() == type)
120 entry[jss::index] =
to_string(sle->key());
126 entry[jss::index] =
to_string(sle->key());
138 org::xrpl::rpc::v1::GetLedgerDataRequest& request = context.
params;
139 org::xrpl::rpc::v1::GetLedgerDataResponse response;
140 grpc::Status status = grpc::Status::OK;
145 grpc::Status errorStatus;
148 errorStatus = grpc::Status(
149 grpc::StatusCode::INVALID_ARGUMENT, status.message());
154 grpc::Status(grpc::StatusCode::NOT_FOUND, status.message());
156 return {response, errorStatus};
164 else if (request.marker().size() != 0)
166 grpc::Status errorStatus{
167 grpc::StatusCode::INVALID_ARGUMENT,
"marker malformed"};
168 return {response, errorStatus};
176 else if (request.end_marker().size() != 0)
178 grpc::Status errorStatus{
179 grpc::StatusCode::INVALID_ARGUMENT,
"end marker malformed"};
180 return {response, errorStatus};
193 response.set_marker(k.data(), k.size());
196 auto stateObject = response.mutable_ledger_objects()->add_objects();
200 stateObject->set_key(sle->key().data(), sle->key().size());
202 return {response, status};
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
@ ltANY
A special type, matching any ledger entry type.
@ arrayValue
array value (ordered list)
iterator upper_bound(key_type const &key) const
static std::optional< base_uint > fromVoidChecked(T const &from)
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext &context, Json::Value &result)
Look up a ledger from a request and fill a Json::Result with the data representing a ledger.
Json::Value expected_field_error(std::string const &name, std::string const &type)
Value & append(const Value &value)
Append value to array at the end.
std::string serializeHex(STObject const &o)
Serialize an object to a hex string.
@ objectValue
object value (collection of name/value pairs).
Json::Value doLedgerData(RPC::JsonContext &)
sles_type sles
Iterable range of ledger state items.
constexpr int pageLength(bool isBinary)
Maximum number of pages in a LedgerData response.
std::pair< org::xrpl::rpc::v1::GetLedgerDataResponse, grpc::Status > doLedgerDataGrpc(RPC::GRPCContext< org::xrpl::rpc::v1::GetLedgerDataRequest > &context)
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::pair< RPC::Status, LedgerEntryType > chooseLedgerEntryType(Json::Value const ¶ms)
Blob const & peekData() const
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Status ledgerFromRequest(T &ledger, GRPCContext< R > &context)
std::string asString() const
Returns the unquoted string value.