From 6b53fe9fb4c6c7cb4128ff564743fee66f2e1635 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 2 Nov 2016 06:12:21 -0300 Subject: [PATCH] test --- iguana/dPoW.h | 2 ++ iguana/dpow/dpow_fsm.c | 14 +++++++------- iguana/iguana_notary.c | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index ada965b9b..4c3b46ede 100755 --- a/iguana/dPoW.h +++ b/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) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index e2f7f7cb1..f2cef3b26 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/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; diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 09b5b2ddd..d815142a6 100755 --- a/iguana/iguana_notary.c +++ b/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 )