Small cleanups and comment additions. Don't sleep after proof of work found.

This commit is contained in:
Jeff Garzik 2010-11-25 00:36:40 -05:00 committed by Jeff Garzik
parent ea6c1126ec
commit 67d3c91317

View file

@ -29,7 +29,6 @@
enum {
STAT_SLEEP_INTERVAL = 10,
POW_SLEEP_INTERVAL = 1,
STAT_CTR_INTERVAL = 10000000,
};
@ -43,7 +42,7 @@ static uint64_t hash_ctr;
static struct argp_option options[] = {
{ "threads", 't', "N", 0,
"Number of miner threads" },
"Number of miner threads (default: 1)" },
{ "debug", 'D', NULL, 0,
"Enable debug output" },
{ "protocol-dump", 'P', NULL, 0,
@ -76,17 +75,6 @@ struct work {
BIGNUM *target;
};
#define ___constant_swab32(x) ((u32)( \
(((u32)(x) & (u32)0x000000ffUL) << 24) | \
(((u32)(x) & (u32)0x0000ff00UL) << 8) | \
(((u32)(x) & (u32)0x00ff0000UL) >> 8) | \
(((u32)(x) & (u32)0xff000000UL) >> 24)))
static inline uint32_t swab32(uint32_t v)
{
return ___constant_swab32(v);
}
static void databuf_free(struct data_buffer *db)
{
if (!db)
@ -469,13 +457,9 @@ static void *miner_thread(void *dummy)
work->hash1, work->hash);
/* if nonce found, submit work */
if (nonce) {
if (nonce)
submit_work(work);
fprintf(stderr, "sleeping, after proof-of-work...\n");
sleep(POW_SLEEP_INTERVAL);
}
work_free(work);
}
@ -537,15 +521,18 @@ int main (int argc, char *argv[])
error_t aprc;
int i;
/* parse command line */
aprc = argp_parse(&argp, argc, argv, 0, NULL, NULL);
if (aprc) {
fprintf(stderr, "argp_parse failed: %s\n", strerror(aprc));
return 1;
}
/* set our priority to the highest (aka "nicest, least intrusive") */
if (setpriority(PRIO_PROCESS, 0, 19))
perror("setpriority");
/* start mining threads */
for (i = 0; i < opt_n_threads; i++) {
pthread_t t;
@ -554,11 +541,12 @@ int main (int argc, char *argv[])
return 1;
}
sleep(1); /* don't pound server all at once */
sleep(1); /* don't pound RPC server all at once */
}
fprintf(stderr, "%d miner threads started.\n", opt_n_threads);
/* main loop */
while (program_running) {
sleep(STAT_SLEEP_INTERVAL);
calc_stats();