Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | 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) { | ||||
case RetFormat::JSON: { | case RetFormat::JSON: { | ||||
UniValue mempoolInfoObject = mempoolInfoToJSON(); | UniValue mempoolInfoObject = MempoolInfoToJSON(::g_mempool); | ||||
std::string strJSON = mempoolInfoObject.write() + "\n"; | std::string strJSON = mempoolInfoObject.write() + "\n"; | ||||
req->WriteHeader("Content-Type", "application/json"); | req->WriteHeader("Content-Type", "application/json"); | ||||
req->WriteReply(HTTP_OK, strJSON); | req->WriteReply(HTTP_OK, strJSON); | ||||
return true; | return true; | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
"output format not found (available: json)"); | "output format not found (available: json)"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static bool rest_mempool_contents(Config &config, HTTPRequest *req, | static bool rest_mempool_contents(Config &config, 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); | ||||
switch (rf) { | switch (rf) { | ||||
case RetFormat::JSON: { | case RetFormat::JSON: { | ||||
UniValue mempoolObject = mempoolToJSON(true); | UniValue mempoolObject = MempoolToJSON(::g_mempool, true); | ||||
std::string strJSON = mempoolObject.write() + "\n"; | std::string strJSON = mempoolObject.write() + "\n"; | ||||
req->WriteHeader("Content-Type", "application/json"); | req->WriteHeader("Content-Type", "application/json"); | ||||
req->WriteReply(HTTP_OK, strJSON); | req->WriteReply(HTTP_OK, strJSON); | ||||
return true; | return true; | ||||
} | } | ||||
default: { | default: { | ||||
return RESTERR(req, HTTP_NOT_FOUND, | return RESTERR(req, HTTP_NOT_FOUND, | ||||
▲ Show 20 Lines • Show All 318 Lines • Show Last 20 Lines |