From 04c5de6ad0be0145571275f50d9d7517af172ba5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 25 Apr 2014 13:34:21 +1000 Subject: [PATCH] Store the latest hash, noting when it changes to allow stratum clean notification --- src/stratifier.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index 20cd982a..c8b4c5d5 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -82,6 +82,7 @@ static cklock_t workbase_lock; /* For the hashtable of all workbases */ static workbase_t *workbases; static int workbase_id; +static char lasthash[68]; struct stratum_msg { struct stratum_msg *next; @@ -226,6 +227,7 @@ static void generate_coinbase(ckpool_t *ckp, workbase_t *wb) static void update_base(ckpool_t *ckp) { workbase_t *wb, *tmp, *tmpa; + bool new_block = false; json_t *val; char *buf; @@ -266,6 +268,10 @@ static void update_base(ckpool_t *ckp) wb->gentime = time(NULL); ck_wlock(&workbase_lock); + if (strncmp(wb->prevhash, lasthash, 64)) { + new_block = true; + memcpy(lasthash, wb->prevhash, 65); + } wb->id = workbase_id++; HASH_ITER(hh, workbases, tmp, tmpa) { /* Age old workbases older than 10 minutes old */