From 1048f4a4aecfa22ee1e4b7cc3aa2b8614a5745fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Dec 2016 18:57:49 +0200 Subject: [PATCH] test --- iguana/dpow/dpow_network.c | 4 ++-- iguana/dpow/dpow_tx.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index acf991049..8b617798a 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -600,10 +600,10 @@ void dpow_bestconsensus(struct dpow_block *bp) bp->bestmask = masks[besti], bp->bestk = bestks[besti]; if ( bp->bestmask == 0 || (time(NULL) / 100) != bp->lastepoch ) { - bp->bestmask = dpow_ratifybest(bp->recvmask,bp,&bp->bestk); + bp->bestmask = dpow_notarybest(bp->recvmask,bp,&bp->bestk); if ( (time(NULL) / 60) != bp->lastepoch ) { - bp->lastepoch = (uint32_t)(time(NULL) / 100); + bp->lastepoch = (uint32_t)(time(NULL) / 60); printf("epoch %u\n",bp->lastepoch % bp->numnotaries); sleep(2 + (rand() % 7)); } diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 8888b216c..906300dfc 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -99,6 +99,30 @@ uint64_t dpow_ratifybest(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp) return(bestmask); } +uint64_t dpow_notarybest(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp) +{ + int32_t m,j,k; uint64_t bestmask,mask = bp->require0; + bestmask = 0; + *lastkp = -1; + for (m=j=0; jnumnotaries; j++) + { + k = (j + ((uint32_t)time(NULL) / 60)) % bp->numnotaries; + if ( bp->require0 != 0 && k == 0 ) + continue; + if ( bits256_nonz(bp->notaries[k].src.prev_hash) != 0 && bits256_nonz(bp->notaries[k].dest.prev_hash) != 0 ) + { + mask |= (1LL << k); + if ( ++m == bp->minsigs-bp->require0 ) + { + *lastkp = k; + bestmask = mask | bp->require0; + //printf("m.%d == minsigs.%d (%d %llx)\n",m,bp->minsigs,k,(long long)bestmask); + } + } + } + return(bestmask); +} + uint64_t dpow_maskmin(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp) { int32_t j,m,k; uint64_t bestmask,mask = 0;//bp->require0;