aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArt Forz <artforz@localhost>2011-10-08 04:35:56 +0200
committerArt Forz <artforz@localhost>2011-10-08 04:35:56 +0200
commit99084f8be4de50789345c42ae1e56378496c2981 (patch)
tree4b2e3834b92974bca876db0684a8756da7b8ab3b
parent0941296571ed0c2b7b5953d636907b299a1409e1 (diff)
Make scantime retargeting less granularcpumine
-rw-r--r--cpu-miner.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cpu-miner.c b/cpu-miner.c
index 133183a..b3d1546 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -539,6 +539,7 @@ static void *miner_thread(void *userdata)
struct work work __attribute__((aligned(128)));
unsigned long hashes_done;
struct timeval tv_start, tv_end, diff;
+ int diffms;
uint64_t max64;
bool rc;
@@ -571,11 +572,10 @@ static void *miner_thread(void *userdata)
hashmeter(thr_id, &diff, hashes_done);
/* adjust max_nonce to meet target scan time */
- if (diff.tv_usec > 500000)
- diff.tv_sec++;
- if (diff.tv_sec > 0) {
+ diffms = diff.tv_sec * 1000 + diff.tv_usec / 1000;
+ if (diffms > 0) {
max64 =
- ((uint64_t)hashes_done * opt_scantime) / diff.tv_sec;
+ ((uint64_t)hashes_done * opt_scantime * 1000) / diffms;
if (max64 > 0xfffffffaULL)
max64 = 0xfffffffaULL;
max_nonce = max64;