Changeset View
Changeset View
Standalone View
Standalone View
src/rest.cpp
Show All 31 Lines | enum RetFormat { | ||||
RF_HEX, | RF_HEX, | ||||
RF_JSON, | RF_JSON, | ||||
}; | }; | ||||
static const struct { | static const struct { | ||||
enum RetFormat rf; | enum RetFormat rf; | ||||
const char *name; | const char *name; | ||||
} rf_names[] = { | } rf_names[] = { | ||||
{RF_UNDEF, ""}, {RF_BINARY, "bin"}, {RF_HEX, "hex"}, {RF_JSON, "json"}, | {RF_UNDEF, ""}, | ||||
{RF_BINARY, "bin"}, | |||||
{RF_HEX, "hex"}, | |||||
{RF_JSON, "json"}, | |||||
}; | }; | ||||
struct CCoin { | struct CCoin { | ||||
uint32_t nHeight; | uint32_t nHeight; | ||||
CTxOut out; | CTxOut out; | ||||
CCoin() : nHeight(0) {} | CCoin() : nHeight(0) {} | ||||
explicit CCoin(Coin in) | explicit CCoin(Coin in) | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | static bool rest_headers(Config &config, HTTPRequest *req, | ||||
} | } | ||||
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; | ||||
boost::split(path, param, boost::is_any_of("/")); | boost::split(path, param, boost::is_any_of("/")); | ||||
if (path.size() != 2) { | if (path.size() != 2) { | ||||
return RESTERR(req, HTTP_BAD_REQUEST, "No header count specified. Use " | return RESTERR(req, HTTP_BAD_REQUEST, | ||||
"/rest/headers/<count>/" | "No header count specified. Use " | ||||
"<hash>.<ext>."); | "/rest/headers/<count>/<hash>.<ext>."); | ||||
} | } | ||||
long count = strtol(path[0].c_str(), nullptr, 10); | long count = strtol(path[0].c_str(), nullptr, 10); | ||||
if (count < 1 || count > 2000) { | if (count < 1 || count > 2000) { | ||||
return RESTERR(req, HTTP_BAD_REQUEST, | return RESTERR(req, HTTP_BAD_REQUEST, | ||||
"Header count out of range: " + path[0]); | "Header count out of range: " + path[0]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 547 Lines • Show Last 20 Lines |