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);
110 if (type ==
ltANY || sle->getType() == type)
116 entry[jss::index] =
to_string(sle->key());
122 entry[jss::index] =
to_string(sle->key());
134 org::xrpl::rpc::v1::GetLedgerDataRequest& request = context.
params;
135 org::xrpl::rpc::v1::GetLedgerDataResponse response;
136 grpc::Status status = grpc::Status::OK;
141 grpc::Status errorStatus;
144 errorStatus = grpc::Status(
145 grpc::StatusCode::INVALID_ARGUMENT, status.message());
150 grpc::Status(grpc::StatusCode::NOT_FOUND, status.message());
152 return {response, errorStatus};
160 else if (request.marker().size() != 0)
162 grpc::Status errorStatus{
163 grpc::StatusCode::INVALID_ARGUMENT,
"marker malformed"};
164 return {response, errorStatus};
172 else if (request.end_marker().size() != 0)
174 grpc::Status errorStatus{
175 grpc::StatusCode::INVALID_ARGUMENT,
"end marker malformed"};
176 return {response, errorStatus};
189 response.set_marker(k.data(), k.size());
192 auto stateObject = response.mutable_ledger_objects()->add_objects();
196 stateObject->set_key(sle->key().data(), sle->key().size());
198 return {response, status};
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
@ ltANY
A special type, matching any ledger entry type.
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.