Browse Source

Store the latest hash, noting when it changes to allow stratum clean notification

master
Con Kolivas 11 years ago
parent
commit
04c5de6ad0
  1. 6
      src/stratifier.c

6
src/stratifier.c

@ -82,6 +82,7 @@ static cklock_t workbase_lock;
/* For the hashtable of all workbases */ /* For the hashtable of all workbases */
static workbase_t *workbases; static workbase_t *workbases;
static int workbase_id; static int workbase_id;
static char lasthash[68];
struct stratum_msg { struct stratum_msg {
struct stratum_msg *next; 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) static void update_base(ckpool_t *ckp)
{ {
workbase_t *wb, *tmp, *tmpa; workbase_t *wb, *tmp, *tmpa;
bool new_block = false;
json_t *val; json_t *val;
char *buf; char *buf;
@ -266,6 +268,10 @@ static void update_base(ckpool_t *ckp)
wb->gentime = time(NULL); wb->gentime = time(NULL);
ck_wlock(&workbase_lock); ck_wlock(&workbase_lock);
if (strncmp(wb->prevhash, lasthash, 64)) {
new_block = true;
memcpy(lasthash, wb->prevhash, 65);
}
wb->id = workbase_id++; wb->id = workbase_id++;
HASH_ITER(hh, workbases, tmp, tmpa) { HASH_ITER(hh, workbases, tmp, tmpa) {
/* Age old workbases older than 10 minutes old */ /* Age old workbases older than 10 minutes old */

Loading…
Cancel
Save