Skip to content

Commit

Permalink
Added revision version. Set current revision to 2. Full version: v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanadnan committed Aug 20, 2018
1 parent 7f08764 commit 0a7671a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
61 changes: 36 additions & 25 deletions http/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,20 @@ string http::__get_response(const string &url, const string &post_data) {

char *buff = (char *)request.c_str();
int sz = request.size();
int n = 0;

while(sz > 0) {
int n = send(sockfd, buff, sz, 0);
if(n < 0) {
close(sockfd);
return "";
}
n = send(sockfd, buff, sz, 0);
if(n < 0) break;
buff+=n;
sz-=n;
}

if(n < 0) {
close(sockfd);
continue;
}

http_parser_settings settings;
memset(&settings, 0, sizeof(settings));
settings.on_body = http_callback;
Expand All @@ -181,28 +185,35 @@ string http::__get_response(const string &url, const string &post_data) {
http_parser_init(&parser, HTTP_RESPONSE);
parser.data = (void *)&reply;

fd_set fds ;
timeval tv ;
int n;

FD_ZERO(&fds) ;
FD_SET(sockfd, &fds) ;

tv.tv_sec = 10;
tv.tv_usec = 0;

n = select(sockfd+1, &fds, NULL, NULL, &tv);
if (n <= 0) {
close(sockfd);
return "";
fd_set fds;
timeval tv;

time_t timestamp = time(NULL);
while(time(NULL) - timestamp < 10) {
FD_ZERO(&fds);
FD_SET(sockfd, &fds);

tv.tv_sec = 0;
tv.tv_usec = 100000;

n = select(sockfd + 1, &fds, NULL, NULL, &tv);
if(n == 0)
continue;
else if(n < 0)
break;
else {
char buffer[2048];
n = recv(sockfd, buffer, 2048, 0);
if (n > 0)
http_parser_execute(&parser, &settings, buffer, n);
else if(n <= 0)
break;

if (reply != "")
break;
}
}

char buffer[2048];
n = recv(sockfd, buffer, 2048, 0);

if(n > 0)
http_parser_execute(&parser, &settings, buffer, n);

close(sockfd);

if(reply != "")
Expand Down
19 changes: 12 additions & 7 deletions miner/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void miner::__display_report() {

time_t total_time = time(NULL) - __begin_time;

if(!__args.is_verbose() || hashers.size() == 1) {
if(!__args.is_verbose()) {
for (vector<hasher *>::iterator it = hashers.begin(); it != hashers.end(); ++it) {
hash_rate += (*it)->get_current_hash_rate();
avg_hash_rate_cblocks += (*it)->get_avg_hash_rate_cblocks();
Expand Down Expand Up @@ -240,13 +240,18 @@ void miner::__display_report() {
"Hash rate: " << setw(6)<< (*it)->get_current_hash_rate() << " H/s " <<
"Avg. (Cblocks): " << setw(6) << (*it)->get_avg_hash_rate_cblocks() << " H/s " <<
"Avg. (Gblocks): " << setw(6) << (*it)->get_avg_hash_rate_gblocks() << " " <<
"Count: " << setw(4) << ((*it)->get_hash_count_cblocks() + (*it)->get_hash_count_gblocks()) << endl;
"Count: " << setw(4) << ((*it)->get_hash_count_cblocks() + (*it)->get_hash_count_gblocks());

if(hashers.size() > 1)
ss << endl;
}
if(hashers.size() > 1) {
ss << fixed << setprecision(2) << "--> ALL " <<
"Hash rate: " << setw(6) << hash_rate << " H/s " <<
"Avg. (Cblocks): " << setw(6) << avg_hash_rate_cblocks << " H/s " <<
"Avg. (Gblocks): " << setw(6) << avg_hash_rate_gblocks << " " <<
"Count: " << setw(4) << (hash_count_cblocks + hash_count_gblocks);
}
ss << fixed << setprecision(2) << "--> ALL " <<
"Hash rate: " << setw(6) << hash_rate << " H/s " <<
"Avg. (Cblocks): " << setw(6) << avg_hash_rate_cblocks << " H/s " <<
"Avg. (Gblocks): " << setw(6) << avg_hash_rate_gblocks << " " <<
"Count: " << setw(4) << (hash_count_cblocks + hash_count_gblocks);
}

LOG(ss.str());
Expand Down

0 comments on commit 0a7671a

Please sign in to comment.