Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cpu-miner.c #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ int longpoll_thr_id = -1;
int stratum_thr_id = -1;
struct work_restart *work_restart = NULL;
static struct stratum_ctx stratum;
unsigned long snd,rcv,msecs;
struct timeval tr,ts;

pthread_mutex_t applog_lock;
static pthread_mutex_t stats_lock;
Expand Down Expand Up @@ -685,7 +687,10 @@ static void share_result(int result, const char *reason)
char s[345];
double hashrate;
int i;


gettimeofday(&tr, NULL); // get current time
rcv = tr.tv_sec*1000 + tr.tv_usec/1000; // calculate milliseconds
msecs=rcv-snd;
hashrate = 0.;
pthread_mutex_lock(&stats_lock);
for (i = 0; i < opt_n_threads; i++)
Expand All @@ -694,8 +699,8 @@ static void share_result(int result, const char *reason)
pthread_mutex_unlock(&stats_lock);

sprintf(s, hashrate >= 1e3 ? "%.0f" : "%.1f", hashrate);
applog(LOG_INFO, "accepted: %lu/%lu (%.2f%%), %s hash/s %s",
accepted_count,
applog(LOG_INFO, "accepted %lums: %lu/%lu (%.2f%%), %s hash/s %s",
msecs,accepted_count,
accepted_count + rejected_count,
100. * accepted_count / (accepted_count + rejected_count),
s,
Expand All @@ -719,6 +724,9 @@ static bool submit_upstream_work(CURL *curl, struct work *work)
applog(LOG_DEBUG, "DEBUG: stale work detected, discarding");
return true;
}

gettimeofday(&ts, NULL); // get current time
snd = ts.tv_sec*1000 + ts.tv_usec/1000; // calculate milliseconds

if (have_stratum) {
unsigned char ntime[4], nonce[4];
Expand Down