I would like totally explanations about Bitcoin Hash Fee past the trivial ones like:
“Hashrate” refers back to the whole mixed computational energy that’s
getting used to mine and course of transactions on a Proof-of-Work
blockchain.
I’ll use two cpuminer capabilities to formulate my query:
share_result and applog. (applog is known as by share_result, so it’s importante to incorporate it right here.)
(look the capabilities on the backside after which return to the query)
I’ve tried to grasp the code however I have not discovered any clarification the place the variable hashrate
will probably be used.
Please, clarify this element.
static void share_result(int outcome, const char *purpose)
{
char s[345];
double hashrate;
int i;
hashrate = 0.;
pthread_mutex_lock(&stats_lock);
for (i = 0; i < opt_n_threads; i++)
hashrate += thr_hashrates[i];
outcome ? accepted_count++ : rejected_count++;
pthread_mutex_unlock(&stats_lock);
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate);
applog(LOG_INFO, "accepted: %lu/%lu (%.2f%%), %s khash/s %s",
accepted_count,
accepted_count + rejected_count,
100. * accepted_count / (accepted_count + rejected_count),
s,
outcome ? "(yay!!!)" : "(booooo)");
if (opt_debug && purpose)
applog(LOG_DEBUG, "DEBUG: reject purpose: %s", purpose);
}
void applog(int prio, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
#ifdef HAVE_SYSLOG_H
if (use_syslog) {
va_list ap2;
char *buf;
int len;
va_copy(ap2, ap);
len = vsnprintf(NULL, 0, fmt, ap2) + 1;
va_end(ap2);
buf = alloca(len);
if (vsnprintf(buf, len, fmt, ap) >= 0)
syslog(prio, "%s", buf);
}
#else
if (0) {}
#endif
else {
char *f;
int len;
time_t now;
struct tm tm, *tm_p;
time(&now);
pthread_mutex_lock(&applog_lock);
tm_p = localtime(&now);
memcpy(&tm, tm_p, sizeof(tm));
pthread_mutex_unlock(&applog_lock);
len = 40 + strlen(fmt) + 2;
f = alloca(len);
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %sn",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
fmt);
pthread_mutex_lock(&applog_lock);
vfprintf(stderr, f, ap); /* atomic write to stderr */
fflush(stderr);
pthread_mutex_unlock(&applog_lock);
}
va_end(ap);
}