Browse Source

test

etomic
jl777 8 years ago
parent
commit
1048f4a4ae
  1. 4
      iguana/dpow/dpow_network.c
  2. 24
      iguana/dpow/dpow_tx.c

4
iguana/dpow/dpow_network.c

@ -600,10 +600,10 @@ void dpow_bestconsensus(struct dpow_block *bp)
bp->bestmask = masks[besti], bp->bestk = bestks[besti]; bp->bestmask = masks[besti], bp->bestk = bestks[besti];
if ( bp->bestmask == 0 || (time(NULL) / 100) != bp->lastepoch ) 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 ) 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); printf("epoch %u\n",bp->lastepoch % bp->numnotaries);
sleep(2 + (rand() % 7)); sleep(2 + (rand() % 7));
} }

24
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); 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; j<bp->numnotaries; 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) 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; int32_t j,m,k; uint64_t bestmask,mask = 0;//bp->require0;

Loading…
Cancel
Save