Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | static bool CheckWarmup(HTTPRequest *req) { | ||||
if (RPCIsInWarmup(&statusmessage)) { | if (RPCIsInWarmup(&statusmessage)) { | ||||
return RESTERR(req, HTTP_SERVICE_UNAVAILABLE, | return RESTERR(req, HTTP_SERVICE_UNAVAILABLE, | ||||
"Service temporarily unavailable: " + statusmessage); | "Service temporarily unavailable: " + statusmessage); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_headers(Config &config, HTTPRequest *req, | static bool rest_headers(Config &config, RPCServer &rpcServer, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string param; | std::string param; | ||||
const RetFormat rf = ParseDataFormat(param, strURIPart); | const RetFormat rf = ParseDataFormat(param, strURIPart); | ||||
std::vector<std::string> path; | std::vector<std::string> path; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
} | } | ||||
} | } | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_block(const Config &config, HTTPRequest *req, | static bool rest_block(const Config &config, RPCServer &rpcServer, | ||||
const std::string &strURIPart, bool showTxDetails) { | HTTPRequest *req, const std::string &strURIPart, | ||||
bool showTxDetails) { | |||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string hashStr; | std::string hashStr; | ||||
const RetFormat rf = ParseDataFormat(hashStr, strURIPart); | const RetFormat rf = ParseDataFormat(hashStr, strURIPart); | ||||
uint256 hash; | uint256 hash; | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
} | } | ||||
} | } | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_block_extended(Config &config, HTTPRequest *req, | static bool rest_block_extended(Config &config, RPCServer &rpcServer, | ||||
HTTPRequest *req, | |||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
return rest_block(config, req, strURIPart, true); | return rest_block(config, rpcServer, req, strURIPart, true); | ||||
} | } | ||||
static bool rest_block_notxdetails(Config &config, HTTPRequest *req, | static bool rest_block_notxdetails(Config &config, RPCServer &rpcServer, | ||||
HTTPRequest *req, | |||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
return rest_block(config, req, strURIPart, false); | return rest_block(config, rpcServer, req, strURIPart, false); | ||||
} | } | ||||
static bool rest_chaininfo(Config &config, HTTPRequest *req, | static bool rest_chaininfo(Config &config, RPCServer &rpcServer, | ||||
const std::string &strURIPart) { | HTTPRequest *req, const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string param; | std::string param; | ||||
const RetFormat rf = ParseDataFormat(param, strURIPart); | const RetFormat rf = ParseDataFormat(param, strURIPart); | ||||
switch (rf) { | switch (rf) { | ||||
Show All 12 Lines | switch (rf) { | ||||
} | } | ||||
} | } | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_mempool_info(Config &config, HTTPRequest *req, | static bool rest_mempool_info(Config &config, RPCServer &rpcServer, | ||||
const std::string &strURIPart) { | HTTPRequest *req, const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string param; | std::string param; | ||||
const RetFormat rf = ParseDataFormat(param, strURIPart); | const RetFormat rf = ParseDataFormat(param, strURIPart); | ||||
switch (rf) { | switch (rf) { | ||||
Show All 11 Lines | switch (rf) { | ||||
} | } | ||||
} | } | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_mempool_contents(Config &config, HTTPRequest *req, | static bool rest_mempool_contents(Config &config, RPCServer &rpcServer, | ||||
HTTPRequest *req, | |||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string param; | std::string param; | ||||
const RetFormat rf = ParseDataFormat(param, strURIPart); | const RetFormat rf = ParseDataFormat(param, strURIPart); | ||||
Show All 12 Lines | switch (rf) { | ||||
} | } | ||||
} | } | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_tx(Config &config, HTTPRequest *req, | static bool rest_tx(Config &config, RPCServer &rpcServer, HTTPRequest *req, | ||||
const std::string &strURIPart) { | const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string hashStr; | std::string hashStr; | ||||
const RetFormat rf = ParseDataFormat(hashStr, strURIPart); | const RetFormat rf = ParseDataFormat(hashStr, strURIPart); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | switch (rf) { | ||||
} | } | ||||
} | } | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static bool rest_getutxos(Config &config, HTTPRequest *req, | static bool rest_getutxos(Config &config, RPCServer &rpcServer, | ||||
const std::string &strURIPart) { | HTTPRequest *req, const std::string &strURIPart) { | ||||
if (!CheckWarmup(req)) { | if (!CheckWarmup(req)) { | ||||
return false; | return false; | ||||
} | } | ||||
std::string param; | std::string param; | ||||
const RetFormat rf = ParseDataFormat(param, strURIPart); | const RetFormat rf = ParseDataFormat(param, strURIPart); | ||||
std::vector<std::string> uriParts; | std::vector<std::string> uriParts; | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | static bool rest_getutxos(Config &config, RPCServer &rpcServer, | ||||
// not reached | // not reached | ||||
// continue to process further HTTP reqs on this cxn | // continue to process further HTTP reqs on this cxn | ||||
return true; | return true; | ||||
} | } | ||||
static const struct { | static const struct { | ||||
const char *prefix; | const char *prefix; | ||||
bool (*handler)(Config &config, HTTPRequest *req, | bool (*handler)(Config &config, RPCServer &rpcServer, HTTPRequest *req, | ||||
const std::string &strReq); | const std::string &strReq); | ||||
} uri_prefixes[] = { | } uri_prefixes[] = { | ||||
{"/rest/tx/", rest_tx}, | {"/rest/tx/", rest_tx}, | ||||
{"/rest/block/notxdetails/", rest_block_notxdetails}, | {"/rest/block/notxdetails/", rest_block_notxdetails}, | ||||
{"/rest/block/", rest_block_extended}, | {"/rest/block/", rest_block_extended}, | ||||
{"/rest/chaininfo", rest_chaininfo}, | {"/rest/chaininfo", rest_chaininfo}, | ||||
{"/rest/mempool/info", rest_mempool_info}, | {"/rest/mempool/info", rest_mempool_info}, | ||||
{"/rest/mempool/contents", rest_mempool_contents}, | {"/rest/mempool/contents", rest_mempool_contents}, | ||||
Show All 20 Lines |