Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static CTxMemPool *GetMemPool(const util::Ref &context, HTTPRequest *req) { | static CTxMemPool *GetMemPool(const util::Ref &context, HTTPRequest *req) { | ||||
NodeContext *node = | NodeContext *node = | ||||
context.Has<NodeContext>() ? &context.Get<NodeContext>() : nullptr; | context.Has<NodeContext>() ? &context.Get<NodeContext>() : nullptr; | ||||
if (!node || !node->mempool) { | if (!node || !node->mempool) { | ||||
RESTERR(req, HTTP_NOT_FOUND, "Mempool disabled or instance not found"); | RESTERR(req, HTTP_NOT_FOUND, "Mempool disabled or instance not found"); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
return node->mempool; | return node->mempool.get(); | ||||
} | } | ||||
static RetFormat ParseDataFormat(std::string ¶m, | static RetFormat ParseDataFormat(std::string ¶m, | ||||
const std::string &strReq) { | const std::string &strReq) { | ||||
const std::string::size_type pos = strReq.rfind('.'); | const std::string::size_type pos = strReq.rfind('.'); | ||||
if (pos == std::string::npos) { | if (pos == std::string::npos) { | ||||
param = strReq; | param = strReq; | ||||
return rf_names[0].rf; | return rf_names[0].rf; | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | static bool rest_tx(Config &config, const util::Ref &context, HTTPRequest *req, | ||||
} | } | ||||
const NodeContext *const node = GetNodeContext(context, req); | const NodeContext *const node = GetNodeContext(context, req); | ||||
if (!node) { | if (!node) { | ||||
return false; | return false; | ||||
} | } | ||||
BlockHash hashBlock; | BlockHash hashBlock; | ||||
const CTransactionRef tx = | const CTransactionRef tx = | ||||
GetTransaction(/* block_index */ nullptr, node->mempool, txid, | GetTransaction(/* block_index */ nullptr, node->mempool.get(), txid, | ||||
Params().GetConsensus(), hashBlock); | Params().GetConsensus(), hashBlock); | ||||
if (!tx) { | if (!tx) { | ||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); | return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); | ||||
} | } | ||||
switch (rf) { | switch (rf) { | ||||
case RetFormat::BINARY: { | case RetFormat::BINARY: { | ||||
CDataStream ssTx(SER_NETWORK, | CDataStream ssTx(SER_NETWORK, | ||||
▲ Show 20 Lines • Show All 345 Lines • Show Last 20 Lines |