20 #include <ripple/app/ledger/InboundLedgers.h>
21 #include <ripple/app/ledger/LedgerMaster.h>
22 #include <ripple/app/ledger/LedgerToJson.h>
23 #include <ripple/app/main/Application.h>
24 #include <ripple/net/RPCErr.h>
25 #include <ripple/protocol/ErrorCodes.h>
26 #include <ripple/protocol/jss.h>
27 #include <ripple/resource/Fees.h>
28 #include <ripple/rpc/Context.h>
29 #include <ripple/rpc/impl/Tuning.h>
50 if ((hasHash && hasIndex) || !(hasHash || hasIndex))
53 "Exactly one of ledger_hash and ledger_index can be set.");
60 auto const& jsonHash = context.
params[jss::ledger_hash];
61 if (!jsonHash.isString() || !ledgerHash.
parseHex(jsonHash.asString()))
66 auto const& jsonIndex = context.
params[jss::ledger_index];
67 if (!jsonIndex.isInt())
79 ledgerIndex = jsonIndex.asInt();
82 if (ledgerIndex >= ledger->info().seq)
87 auto const j = context.
app.
journal(
"RPCHandler");
89 auto neededHash =
hashOfSeq(*ledger, ledgerIndex, j);
94 auto refHash =
hashOfSeq(*ledger, refIndex, j);
108 "acquiring ledger containing requested index");
109 jvResult[jss::acquiring] =
118 "acquiring ledger containing requested index");
119 jvResult[jss::acquiring] = il->getJson(0);
127 neededHash =
hashOfSeq(*ledger, ledgerIndex, j);
130 ledgerHash = neededHash ? *neededHash : beast::zero;
146 jvResult[jss::ledger_index] = ledger->info().seq;
147 addJson(jvResult, {*ledger, &context, 0});
152 return il->getJson(0);
155 rpcNOT_READY,
"findCreate failed to return an inbound ledger");
@ ledgerMaster
ledger master data for signing
Resource::Charge & loadType
@ rpcREPORTING_UNSUPPORTED
virtual InboundLedgers & getInboundLedgers()=0
virtual LedgerMaster & getLedgerMaster()=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
Json::Value doLedgerRequest(RPC::JsonContext &)
virtual Config & config()=0
bool isMember(const char *key) const
Return true if the object has a member named key.
Json::Value rpcError(int iError, Json::Value jvResult)
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
boost::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual beast::Journal journal(std::string const &name)=0
bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
void addJson(Json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a Json::Object or Json::Value with a description of the ledger.
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Json::Value make_param_error(std::string const &message)
Returns a new json object that indicates invalid parameters.
Json::Value invalid_field_error(std::string const &name)
const Charge feeHighBurdenRPC
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
constexpr auto maxValidatedLedgerAge
virtual std::shared_ptr< InboundLedger > find(LedgerHash const &hash)=0