Skip to content

Commit

Permalink
Updated curl::xfer without useless debug param.
Browse files Browse the repository at this point in the history
Free Software Free Society

To increase the frequency of commits by ctubio,
you can buy-me-a-drink with a small git-tip at:
  1GitTipB6sY2YSbkH3BJHepUB7Cjymi9R1 (BTC addr)

To force me to write more source documentation,
you can buy-me-a-drink with a small doc-tip at:
  1KDocsmbhUEh7JgmYjuMH3nDivzSM6dphP (BTC addr)

I promise to drink chocolate milk after commit.

To request new features or in case this commit breaks something for you,
please, create a new github issue with all possible information for me,
but never share your API Keys!

Signed-off-by: Carles Tubio <[email protected]>
  • Loading branch information
ctubio committed May 21, 2019
1 parent e3fe179 commit 4bcde02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ K ?= K.sh
MAJOR = 0
MINOR = 4
PATCH = 13
BUILD = 45
BUILD = 46
SOURCE := $(notdir $(wildcard src/bin/*))
CARCH = x86_64-linux-gnu \
arm-linux-gnueabihf \
Expand Down
14 changes: 8 additions & 6 deletions src/lib/Krypto.ninja-apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace ₿ {
static const json xfer(const string &url, const long &timeout = 13) {
return perform(url, [&](CURL *curl) {
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
}, timeout == 13);
});
};
static const json xfer(const string &url, const string &post) {
return perform(url, [&](CURL *curl) {
Expand All @@ -165,7 +165,7 @@ namespace ₿ {
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.data());
});
};
static const json perform(const string &url, const function<void(CURL*)> custom_setopt, const bool debug = true) {
static const json perform(const string &url, const function<void(CURL*)> custom_setopt) {
static mutex waiting_reply;
lock_guard<mutex> lock(waiting_reply);
string reply;
Expand All @@ -180,12 +180,14 @@ namespace ₿ {
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return (debug and res != CURLE_OK)
? (json){ {"error", string("CURL Error: ") + curl_easy_strerror(res)} }
: (json::accept(reply)
return res == CURLE_OK
? (json::accept(reply)
? json::parse(reply)
: json::object()
);
)
: (json){
{"error", string("CURL Error: ") + curl_easy_strerror(res)}
};
};
private:
static size_t write(void *buf, size_t size, size_t nmemb, void *reply) {
Expand Down

0 comments on commit 4bcde02

Please sign in to comment.