Browse Source

test

olddPoW
jl777 8 years ago
parent
commit
6b53fe9fb4
  1. 2
      iguana/dPoW.h
  2. 14
      iguana/dpow/dpow_fsm.c
  3. 1
      iguana/iguana_notary.c

2
iguana/dPoW.h

@ -16,6 +16,8 @@
#ifndef INCLUDE_DPOW_H
#define INCLUDE_DPOW_H
#define DPOW_FIRSTRATIFY 1000
#define DPOW_CHECKPOINTFREQ 10
#define DPOW_MINSIGS 7
#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1)

14
iguana/dpow/dpow_fsm.c

@ -452,11 +452,11 @@ void dpow_statemachinestart(void *ptr)
dp->blocks[checkpoint.blockhash.height] = bp;
bp->beacon = rand256(0);
vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon));
if ( checkpoint.blockhash.height > 0 && dp->blocks[checkpoint.blockhash.height - 1000] != 0 )
if ( checkpoint.blockhash.height >= DPOW_FIRSTRATIFY && dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] != 0 )
{
printf("purge %s.%d\n",dp->dest,checkpoint.blockhash.height - 1000);
free(dp->blocks[checkpoint.blockhash.height - 1000]);
dp->blocks[checkpoint.blockhash.height - 1000] = 0;
printf("purge %s.%d\n",dp->dest,checkpoint.blockhash.height - DPOW_FIRSTRATIFY);
free(dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY]);
dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] = 0;
}
}
bitcoin_address(srcaddr,src->chain->pubtype,dp->minerkey33,33);
@ -524,7 +524,7 @@ void dpow_statemachinestart(void *ptr)
bp->hashmsg = checkpoint.blockhash.hash;
while ( dp->destupdated == 0 )
{
if ( checkpoint.blockhash.height != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height )
if ( checkpoint.blockhash.height >= DPOW_FIRSTRATIFY && dp->checkpoint.blockhash.height > checkpoint.blockhash.height )
{
printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
return;
@ -539,7 +539,7 @@ void dpow_statemachinestart(void *ptr)
while ( time(NULL) < starttime+bp->duration && src != 0 && dest != 0 && bp->state != 0xffffffff )
{
sleep(2);
if ( checkpoint.blockhash.height != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height )
if ( checkpoint.blockhash.height >= DPOW_FIRSTRATIFY && dp->checkpoint.blockhash.height > checkpoint.blockhash.height )
{
printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
break;
@ -549,7 +549,7 @@ void dpow_statemachinestart(void *ptr)
//printf("dp->ht.%d ht.%d DEST.%08x %s\n",dp->checkpoint.blockhash.height,checkpoint.blockhash.height,deststate,bits256_str(str,srchash.hash));
bp->state = dpow_statemachineiterate(myinfo,dp,dest,bp,myind,1);
}
if ( dp->cancelratify != 0 && checkpoint.blockhash.height == 0 )
if ( dp->cancelratify != 0 && checkpoint.blockhash.height < DPOW_FIRSTRATIFY )
{
printf("abort pending ratify\n");
break;

1
iguana/iguana_notary.c

@ -367,6 +367,7 @@ TWOINTS_AND_ARRAY(dpow,ratify,minsigs,timestamp,ratified)
ptrs[2] = (void *)(long)minsigs;
ptrs[3] = (void *)DPOW_RATIFYDURATION;
ptrs[4] = (void *)jprint(ratified,0);
checkpoint.blockhash.height = (timestamp % DPOW_FIRSTRATIFY) * 10;
memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint));
myinfo->DPOWS[0].cancelratify = 0;
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )

Loading…
Cancel
Save