20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/TransactionMaster.h>
22 #include <ripple/app/misc/NetworkOPs.h>
23 #include <ripple/app/misc/Transaction.h>
24 #include <ripple/basics/ToString.h>
25 #include <ripple/net/RPCErr.h>
26 #include <ripple/protocol/ErrorCodes.h>
27 #include <ripple/protocol/jss.h>
28 #include <ripple/rpc/Context.h>
29 #include <ripple/rpc/DeliveredAmount.h>
30 #include <ripple/rpc/GRPCHandlers.h>
31 #include <ripple/rpc/NFTSyntheticSerializer.h>
32 #include <ripple/rpc/impl/RPCHelpers.h>
73 Throw<std::runtime_error>(
74 "Called doTxPostgres yet not in reporting mode");
79 JLOG(context.
j.
debug()) <<
"Fetching from postgres";
99 return {res, {
rpcINTERNAL,
"Error making SHAMap node"}};
101 auto item = (
static_cast<SHAMapLeafNode*
>(node.get()))->peekItem();
105 return {res, {
rpcINTERNAL,
"Error reading SHAMap node"}};
109 JLOG(context.
j.
debug()) <<
"Successfully fetched from db";
114 return {res, {
rpcINTERNAL,
"Error deserializing SHAMap node"}};
117 res.
txn = std::make_shared<Transaction>(sttx, reason, context.
app);
125 res.
meta = std::move(blob);
129 res.
meta = std::make_shared<TxMeta>(
137 JLOG(context.
j.
error()) <<
"Failed to fetch from db";
139 return {res, {
rpcINTERNAL,
"Containing SHAMap node not found"}};
142 JLOG(context.
j.
debug()) <<
"tx flat fetch time : "
143 << ((end - start).count() / 1000000000.0);
154 if (min >=
range.lower() && max <=
range.upper())
167 return {res, {
rpcINTERNAL,
"unexpected Postgres response"}};
181 constexpr uint16_t MAX_RANGE = 1000;
210 if (
auto e = std::get_if<TxSearched>(&v))
216 auto [txn, meta] = std::get<TxPair>(v);
229 if (txn->getLedger() == 0)
241 result.
meta = meta->getAsObject().getSerializer().getData();
270 response[jss::searched_all] =
272 error.inject(response);
276 error.inject(response);
285 if (
auto blob = std::get_if<Blob>(&result.
meta))
297 insertDeliveredAmount(
298 response[jss::meta], context, result.
txn, *meta);
299 insertNFTSyntheticInJson(
303 response[jss::validated] = result.
validated;
virtual Family & getNodeFamily()=0
@ ledgerMaster
ledger master data for signing
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Json::Value getJson(JsonOptions options, bool binary=false) const
std::shared_ptr< STTx const > const & getSTransaction()
Json::Value rpcError(int iError)
uint256 const & getNodestoreHash()
void setLedger(LedgerIndex ledger)
LedgerMaster & ledgerMaster
virtual NodeStore::Database & db()=0
LedgerInfo const & info() const override
Returns information about the ledger.
@ objectValue
object value (collection of name/value pairs).
std::pair< std::shared_ptr< STTx const >, std::shared_ptr< STObject const > > deserializeTxPlusMeta(SHAMapItem const &item)
Deserialize a SHAMapItem containing STTx + STObject metadata.
LedgerIndex getLedger() const
std::optional< std::pair< uint32_t, uint32_t > > ledgerRange
virtual Config & config()=0
static Locator locate(uint256 const &id, Application &app)
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
bool isMember(const char *key) const
Return true if the object has a member named key.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Status represents the results of an operation that might fail.
static std::shared_ptr< SHAMapTreeNode > makeFromPrefix(Slice rawNode, SHAMapHash const &hash)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value populateJsonResponse(std::pair< AccountTxResult, RPC::Status > const &res, AccountTxArgs const &args, RPC::JsonContext const &context)
std::pair< TxResult, RPC::Status > doTxPostgres(RPC::Context &context, TxArgs const &args)
std::pair< TxResult, RPC::Status > doTxHelp(RPC::Context &context, TxArgs const &args)
void setStatus(TransStatus status, std::uint32_t ledgerSeq)
Json::Value doTxJson(RPC::JsonContext &)
std::variant< std::shared_ptr< TxMeta >, Blob > meta
std::variant< std::pair< std::shared_ptr< Transaction >, std::shared_ptr< TxMeta > >, TxSearched > fetch(uint256 const &, error_code_i &ec)
std::string strHex(FwdIt begin, FwdIt end)
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t ledgerSeq=0, FetchType fetchType=FetchType::synchronous, bool duplicate=false)
Fetch a node object.
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
static bool isValidated(LedgerMaster &ledgerMaster, std::uint32_t seq, uint256 const &hash)
uint32_t getLedgerSequence()
The context of information needed to call an RPC.
std::string asString() const
Returns the unquoted string value.
virtual TransactionMaster & getMasterTransaction()=0
ClosedInterval< uint32_t > const & getLedgerRangeSearched()