diff --git a/cpu-miner.c b/cpu-miner.c index d88e7bba..38a91498 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -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();