aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-cli.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2022-03-30 10:56:48 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-03-30 14:00:12 +0200
commit0598f36852199d0cee8fe9e676a2e0bec3ebf624 (patch)
tree7e0c22f91f039e49c632bcee8bec63504ce8f818 /src/bitcoin-cli.cpp
parentaaf72d62c18f9cb325c150cf0cc21abb201607c8 (diff)
downloadbitcoin-0598f36852199d0cee8fe9e676a2e0bec3ebf624.tar.xz
refactor: account for requiring libevent 2.1.8+
Diffstat (limited to 'src/bitcoin-cli.cpp')
-rw-r--r--src/bitcoin-cli.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 5523fff3b2..6925a4c8c6 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -184,7 +184,6 @@ struct HTTPReply
static std::string http_errorstring(int code)
{
switch(code) {
-#if LIBEVENT_VERSION_NUMBER >= 0x02010300
case EVREQ_HTTP_TIMEOUT:
return "timeout reached";
case EVREQ_HTTP_EOF:
@@ -197,7 +196,6 @@ static std::string http_errorstring(int code)
return "request was canceled";
case EVREQ_HTTP_DATA_TOO_LONG:
return "response body is larger than allowed";
-#endif
default:
return "unknown";
}
@@ -228,13 +226,11 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
}
}
-#if LIBEVENT_VERSION_NUMBER >= 0x02010300
static void http_error_cb(enum evhttp_request_error err, void *ctx)
{
HTTPReply *reply = static_cast<HTTPReply*>(ctx);
reply->error = err;
}
-#endif
/** Class that handles the conversion from a command-line to a JSON-RPC request,
* as well as converting back to a JSON object that can be shown as result.
@@ -745,11 +741,11 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
- if (req == nullptr)
+ if (req == nullptr) {
throw std::runtime_error("create http request failed");
-#if LIBEVENT_VERSION_NUMBER >= 0x02010300
+ }
+
evhttp_request_set_error_cb(req.get(), http_error_cb);
-#endif
// Get credentials
std::string strRPCUserColonPass;