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/GRPCHelpers.h>
29 #include <ripple/rpc/impl/RPCHelpers.h>
30 #include <ripple/rpc/impl/Tuning.h>
49 auto const& params = context.
params;
55 bool const isMarker = params.isMember(jss::marker);
64 bool const isBinary = params[jss::binary].asBool();
67 if (params.isMember(jss::limit))
73 limit = jLimit.
asInt();
77 if ((limit < 0) || ((limit > maxLimit) && (!
isUnlimited(context.
role))))
81 jvResult[jss::ledger_index] = lpLedger->
info().
seq;
87 *lpLedger, &context, isBinary ? LedgerFill::Options::binary : 0));
94 rpcStatus.inject(jvResult);
111 if (type ==
ltINVALID || sle->getType() == type)
117 entry[jss::index] =
to_string(sle->key());
123 entry[jss::index] =
to_string(sle->key());
135 org::xrpl::rpc::v1::GetLedgerDataRequest& request = context.
params;
136 org::xrpl::rpc::v1::GetLedgerDataResponse response;
137 grpc::Status status = grpc::Status::OK;
142 grpc::Status errorStatus{
143 grpc::StatusCode::NOT_FOUND,
"ledger not found"};
144 return {response, errorStatus};
148 if (request.marker().size() != 0)
151 if (key.
size() != request.marker().size())
153 grpc::Status errorStatus{
154 grpc::StatusCode::INVALID_ARGUMENT,
"marker malformed"};
155 return {response, errorStatus};
161 if (request.end_marker().size() != 0)
164 if (stopKey.
size() != request.marker().size())
166 grpc::Status errorStatus{
167 grpc::StatusCode::INVALID_ARGUMENT,
"end marker malformed"};
168 return {response, errorStatus};
183 response.set_marker(k.data(), k.size());
186 auto stateObject = response.mutable_ledger_objects()->add_objects();
190 stateObject->set_key(sle->key().data(), sle->key().size());
192 return {response, status};