Skip to content

Commit 0598f36

Browse files
fanquakehebasto
authored andcommitted
refactor: account for requiring libevent 2.1.8+
1 parent aaf72d6 commit 0598f36

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

src/bitcoin-cli.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ struct HTTPReply
184184
static std::string http_errorstring(int code)
185185
{
186186
switch(code) {
187-
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
188187
case EVREQ_HTTP_TIMEOUT:
189188
return "timeout reached";
190189
case EVREQ_HTTP_EOF:
@@ -197,7 +196,6 @@ static std::string http_errorstring(int code)
197196
return "request was canceled";
198197
case EVREQ_HTTP_DATA_TOO_LONG:
199198
return "response body is larger than allowed";
200-
#endif
201199
default:
202200
return "unknown";
203201
}
@@ -228,13 +226,11 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
228226
}
229227
}
230228

231-
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
232229
static void http_error_cb(enum evhttp_request_error err, void *ctx)
233230
{
234231
HTTPReply *reply = static_cast<HTTPReply*>(ctx);
235232
reply->error = err;
236233
}
237-
#endif
238234

239235
/** Class that handles the conversion from a command-line to a JSON-RPC request,
240236
* 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
745741

746742
HTTPReply response;
747743
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
748-
if (req == nullptr)
744+
if (req == nullptr) {
749745
throw std::runtime_error("create http request failed");
750-
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
746+
}
747+
751748
evhttp_request_set_error_cb(req.get(), http_error_cb);
752-
#endif
753749

754750
// Get credentials
755751
std::string strRPCUserColonPass;

src/httpserver.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,12 @@ bool InitHTTPServer()
403403
}
404404

405405
bool UpdateHTTPServerLogging(bool enable) {
406-
#if LIBEVENT_VERSION_NUMBER >= 0x02010100
407406
if (enable) {
408407
event_enable_debug_logging(EVENT_DBG_ALL);
409408
} else {
410409
event_enable_debug_logging(EVENT_DBG_NONE);
411410
}
412411
return true;
413-
#else
414-
// Can't update libevent logging if version < 02010100
415-
return false;
416-
#endif
417412
}
418413

419414
static std::thread g_thread_http;

src/test/fuzz/http_request.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,8 @@
1919
#include <string>
2020
#include <vector>
2121

22-
// workaround for libevent versions before 2.1.1,
23-
// when internal functions didn't have underscores at the end
24-
#if LIBEVENT_VERSION_NUMBER < 0x02010100
25-
extern "C" int evhttp_parse_firstline(struct evhttp_request*, struct evbuffer*);
26-
extern "C" int evhttp_parse_headers(struct evhttp_request*, struct evbuffer*);
27-
inline int evhttp_parse_firstline_(struct evhttp_request* r, struct evbuffer* b)
28-
{
29-
return evhttp_parse_firstline(r, b);
30-
}
31-
inline int evhttp_parse_headers_(struct evhttp_request* r, struct evbuffer* b)
32-
{
33-
return evhttp_parse_headers(r, b);
34-
}
35-
#else
3622
extern "C" int evhttp_parse_firstline_(struct evhttp_request*, struct evbuffer*);
3723
extern "C" int evhttp_parse_headers_(struct evhttp_request*, struct evbuffer*);
38-
#endif
3924

4025
std::string RequestMethodString(HTTPRequest::RequestMethod m);
4126

0 commit comments

Comments
 (0)