From d3e5bb2ce089b3f623a7876b1bd4a2a56b215a86 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 9 Jul 2016 23:51:52 +1000 Subject: [PATCH] ckdb - start a new shift on a halving --- src/ckdb.c | 17 ++++++++++++++++- src/ckdb.h | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index e1479991..5e4f01ba 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -4235,6 +4235,8 @@ ASSERT4((sizeof(shift_words) == (sizeof(char *) * SHIFT_WORDS))); // optioncontrol name to override the SHIFT_DIFF_BLOCK value #define SHIFT_DIFF_BLOCK_STR "ShiftDiffBlock" +#define BLOCK_HALVING 210000 + static void make_a_shift_mark() { K_TREE_CTX ss_ctx[1], m_ctx[1], wi_ctx[1], b_ctx[1]; @@ -4499,7 +4501,7 @@ static void make_a_shift_mark() * changed */ if (strcmp(wi_bits, workinfo->bits) != 0) { if (workinfo->height > (int32_t)shiftdiffblock) { - LOGDEBUG("%s() OK shift stops at diff" + LOGDEBUG("%s() OK shift stops for a diff" " change '%s->%s' %"PRId64 "->%"PRId64" height %"PRId32 " limit %"PRId64, @@ -4512,6 +4514,19 @@ static void make_a_shift_mark() break; } } + // Halving? Stop at the last workinfo before it + if ((workinfo->height % BLOCK_HALVING) == 0) { + LOGDEBUG("%s() OK shift stops for a " + "halving wid %"PRId64 + "->%"PRId64" height %"PRId32 + " halving every %d", + __func__, prev_wid, + workinfo->workinfoid, + workinfo->height, + BLOCK_HALVING); + marks_wid = prev_wid; + break; + } } /* Did we find a pool restart? i.e. a wid skip * These will usually be a much larger jump, diff --git a/src/ckdb.h b/src/ckdb.h index aabf8285..a792a3b8 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.200" +#define CKDB_VERSION DB_VERSION"-2.201" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__