From 6df1711289920fe00da4cf38f1e1c8024c467d47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Mar 2018 23:20:55 +0200 Subject: [PATCH 01/17] Test --- iguana/iguana_notary.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 59483c7eb..291c13b89 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -95,7 +95,8 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( height > 0 && blocktime > 0 ) { dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); - //printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height); + if ( strcmp("BEER",dp->symbol) == 0 ) + printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height); checkpoint = dp->last; } else return; if ( bits256_nonz(dp->activehash) != 0 && bits256_cmp(dp->activehash,checkpoint.blockhash.hash) == 0 ) @@ -108,7 +109,8 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he printf("lastnotarized.(%s) is current checkpoint, skip\n",bits256_str(str,dp->lastnotarized)); return; } - //printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash)); + if ( strcmp("BEER",dp->symbol) == 0 ) + printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash)); } else return; } else return; } else return; @@ -116,7 +118,8 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he } if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 ) { - //printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); + if ( strcmp("BEER",dp->symbol) == 0 ) + printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000); ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t)); ptrs[0] = (void *)myinfo; From 1af5339cb57ce0c03b6a184134fd84fcc7be2bd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Mar 2018 23:31:14 +0200 Subject: [PATCH 02/17] Test --- iguana/dpow/dpow_fsm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 3b500ba50..3eb9d7a63 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -242,6 +242,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t ht,maxdepth = 65536,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); + printf("start MoM calc %d height.%d\n",coin->symbol,height); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { merkle = jbits256(blockjson,"merkleroot"); @@ -333,6 +334,7 @@ void dpow_statemachinestart(void *ptr) if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { bp = calloc(1,sizeof(*bp)); + printf("allocate bp for %s ht.%d -> %s\n",src->symbol,checkpoint.blockhash.height,dest->symbol); Numallocated++; bp->MoM = MoM; bp->MoMdepth = MoMdepth; From d46a00a3835226ee8f2a2e029640ba500db8e693 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Mar 2018 23:48:53 +0200 Subject: [PATCH 03/17] Test --- iguana/dpow/dpow_fsm.c | 26 ++++++++++++++++---------- iguana/iguana_notary.c | 4 ++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 3eb9d7a63..a61eac335 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -162,7 +162,7 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct uint32_t Numallocated; -int32_t dpow_txhasnotarization(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) +int32_t dpow_txhasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) { cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; uint64_t notarymask; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 ) @@ -213,8 +213,11 @@ int32_t dpow_txhasnotarization(struct supernet_info *myinfo,struct iguana_info * if ( numnotaries > 0 ) { if ( numnotaries >= DPOW_MIN_ASSETCHAIN_SIGS ) + { hasnotarization = 1; - printf("numnotaries.%d %s hasnotarization.%d ht.%d\n",numnotaries,coin->symbol,hasnotarization,height); + *nothtp = height - 10; + } + printf("numnotaries.%d %s hasnotarization.%d ht.%d MUSTFIX notht.%d\n",numnotaries,coin->symbol,hasnotarization,height,*nothtp); } } } @@ -223,15 +226,16 @@ int32_t dpow_txhasnotarization(struct supernet_info *myinfo,struct iguana_info * return(hasnotarization); } -int32_t dpow_hasnotarization(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht) +int32_t dpow_hasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht) { int32_t i,n,hasnotarization = 0; bits256 txid; cJSON *txarray; + *nothtp = 0; if ( (txarray= jarray(&n,blockjson,"tx")) != 0 ) { for (i=0; isymbol,height); + printf("start MoM calc %s height.%d\n",coin->symbol,height); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { merkle = jbits256(blockjson,"merkleroot"); @@ -251,16 +255,17 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { merkles = calloc(maxdepth,sizeof(*merkles)); merkles[MoMdepth++] = merkle; - while ( MoMdepth < maxdepth && MoMdepth < height ) + ht = height - MoMdepth; + while ( MoMdepth < maxdepth && MoMdepth < height && ht >= breakht ) { - ht = height - MoMdepth; blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( dpow_hasnotarization(myinfo,coin,blockjson,ht) > 0 ) + if ( notht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) { + breakht = notht; free_json(blockjson); - break; + printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); free_json(blockjson); @@ -279,6 +284,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu MoMdepth = 0; break; } + ht = height - MoMdepth; } if ( MoMdepth > 0 && MoMdepth < maxdepth ) { diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 291c13b89..37c246b3f 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -60,7 +60,7 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime) { - void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht; struct dpow_block *bp; + void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; struct dpow_block *bp; dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); checkpoint = dp->srcfifo[dp->srcconfirms]; if ( strcmp("BTC",dp->dest) == 0 ) @@ -88,7 +88,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( (blockjson= dpow_getblock(myinfo,coin,hash)) != 0 ) { height = jint(blockjson,"height"); - if ( dpow_hasnotarization(myinfo,coin,blockjson,height) <= 0 ) + if ( dpow_hasnotarization(¬ht,myinfo,coin,blockjson,height) <= 0 ) { blocktime = juint(blockjson,"time"); free_json(blockjson); From 7974e977adb025181b8a9a3f9cf613b0b3aa55fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Mar 2018 23:57:56 +0200 Subject: [PATCH 04/17] Test --- iguana/dpow/dpow_fsm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index a61eac335..0bfe1f3ef 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -256,7 +256,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu merkles = calloc(maxdepth,sizeof(*merkles)); merkles[MoMdepth++] = merkle; ht = height - MoMdepth; - while ( MoMdepth < maxdepth && MoMdepth < height && ht >= breakht ) + while ( MoMdepth < maxdepth && ht >= breakht && ht > 0 ) { blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) @@ -300,6 +300,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu } else printf("%s.ht%d null merkles\n",coin->symbol,height); } else printf("%s.ht%d null block\n",coin->symbol,height); *MoMdepthp = MoMdepth; + printf("done MoM calc %s height.%d MoMdepth.%d\n",coin->symbol,height,MoMdepth); return(MoM); } From 0843be758c38fbe6de8e09a2a476263a590ed641 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:01:02 +0200 Subject: [PATCH 05/17] Test --- iguana/dpow/dpow_fsm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 0bfe1f3ef..11969781c 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -258,6 +258,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu ht = height - MoMdepth; while ( MoMdepth < maxdepth && ht >= breakht && ht > 0 ) { + fprintf(stderr,"%s.%d ",coin->symbol,ht); blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { From f02b0771eef3af95d27e0599300e850ec1ad59df Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:10:39 +0200 Subject: [PATCH 06/17] Test --- iguana/dpow/dpow_fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 11969781c..57c981e0c 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -216,8 +216,8 @@ int32_t dpow_txhasnotarization(int32_t *nothtp,struct supernet_info *myinfo,stru { hasnotarization = 1; *nothtp = height - 10; + printf("numnotaries.%d %s hasnotarization.%d ht.%d MUSTFIX notht.%d\n",numnotaries,coin->symbol,hasnotarization,height,*nothtp); } - printf("numnotaries.%d %s hasnotarization.%d ht.%d MUSTFIX notht.%d\n",numnotaries,coin->symbol,hasnotarization,height,*nothtp); } } } From 914f8cada249cfbd9ee44689a4bea16e2fb6ff0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:20:11 +0200 Subject: [PATCH 07/17] Test --- iguana/dpow/dpow_fsm.c | 6 ++++-- iguana/dpow/dpow_rpc.c | 16 ++++++++-------- iguana/iguana777.h | 2 +- iguana/main.c | 1 + 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 57c981e0c..b6c4f3102 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -243,7 +243,7 @@ int32_t dpow_hasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct iguana_info *coin,int32_t height) { - bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 65536,MoMdepth = 0; + bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 20000,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); printf("start MoM calc %s height.%d\n",coin->symbol,height); @@ -258,7 +258,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu ht = height - MoMdepth; while ( MoMdepth < maxdepth && ht >= breakht && ht > 0 ) { - fprintf(stderr,"%s.%d ",coin->symbol,ht); + //fprintf(stderr,"%s.%d ",coin->symbol,ht); blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { @@ -337,7 +337,9 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; + portable_mutex_lock(&myinfo->MoM_mutex); MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); + portable_mutex_unlock(&myinfo->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 7ed3d7710..a39721b14 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -43,7 +43,7 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) { buf[0] = 0; retstr = bitcoind_getinfo(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->getinfostr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -304,7 +304,7 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2 retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getblock",buf); if ( 0 && strcmp(coin->symbol,"USD") == 0 ) printf("%s getblock.(%s)\n",coin->symbol,retstr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -329,7 +329,7 @@ char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin { sprintf(buf,"\"%s\"",address); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"validateaddress",buf); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -349,7 +349,7 @@ cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits2 if ( coin->FULLNODE < 0 ) { retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"gettxout",buf); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -380,7 +380,7 @@ char *dpow_decoderawtransaction(struct supernet_info *myinfo,struct iguana_info retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"decoderawtransaction",paramstr); //printf("%s decoderawtransaction.(%s) <- (%s)\n",coin->symbol,retstr,paramstr); free(paramstr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -402,7 +402,7 @@ cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getrawtransaction",buf)) != 0 ) { } - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -509,7 +509,7 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"signrawtransaction",paramstr); //printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr); free(paramstr); - usleep(10000); + usleep(1000); return(retstr); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) @@ -1298,7 +1298,7 @@ int32_t dpow_issuer_iteration(struct dpow_info *dp,struct iguana_info *coin,int3 printf("error height %d\n",height); break; } - usleep(10000); + usleep(1000); } if ( height >= currentheight ) *isrealtimep = (uint32_t)time(NULL); diff --git a/iguana/iguana777.h b/iguana/iguana777.h index eb058e620..02dbc4e84 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -159,7 +159,7 @@ struct supernet_info struct exchange_info *tradingexchanges[SUPERNET_MAXEXCHANGES]; int32_t numexchanges; struct iguana_waccount *wallet; struct iguana_info *allcoins; int32_t allcoins_being_added,allcoins_numvirts; - portable_mutex_t bu_mutex,allcoins_mutex,gecko_mutex,basilisk_mutex,DEX_mutex,DEX_reqmutex,DEX_swapmutex,smart_mutex; + portable_mutex_t bu_mutex,allcoins_mutex,gecko_mutex,basilisk_mutex,DEX_mutex,DEX_reqmutex,DEX_swapmutex,smart_mutex,MoM_mutex; struct queueitem *DEX_quotes; cJSON *Cunspents,*Cspends; struct basilisk_swap *swaps[256]; int32_t numswaps; struct basilisk_message *messagetable; portable_mutex_t messagemutex; queue_t msgQ,p2pQ; diff --git a/iguana/main.c b/iguana/main.c index de0f6d32d..0bb573287 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -2245,6 +2245,7 @@ void iguana_main(void *arg) strcpy(myinfo->rpcsymbol,"BTCD"); iguana_urlinit(myinfo,ismainnet,usessl); portable_mutex_init(&myinfo->pending_mutex); + portable_mutex_init(&myinfo->MoM_mutex); portable_mutex_init(&myinfo->dpowmutex); portable_mutex_init(&myinfo->notarymutex); portable_mutex_init(&myinfo->psockmutex); From e47daaa5522329f453baaf36dbe1f7ad199e3820 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:28:49 +0200 Subject: [PATCH 08/17] Test --- iguana/dpow/dpow_fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index b6c4f3102..53617680e 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -243,7 +243,7 @@ int32_t dpow_hasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct iguana_info *coin,int32_t height) { - bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 20000,MoMdepth = 0; + bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 256,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); printf("start MoM calc %s height.%d\n",coin->symbol,height); From 8d9dd8c8a79c5a4da840d9d4ea9177f3dad484b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:41:52 +0200 Subject: [PATCH 09/17] Test --- iguana/dpow/dpow_fsm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 53617680e..244bfb3a6 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -246,7 +246,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 256,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); - printf("start MoM calc %s height.%d\n",coin->symbol,height); + //printf("start MoM calc %s height.%d\n",coin->symbol,height); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { merkle = jbits256(blockjson,"merkleroot"); @@ -266,7 +266,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { breakht = notht; free_json(blockjson); - printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); + //printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); free_json(blockjson); @@ -301,7 +301,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu } else printf("%s.ht%d null merkles\n",coin->symbol,height); } else printf("%s.ht%d null block\n",coin->symbol,height); *MoMdepthp = MoMdepth; - printf("done MoM calc %s height.%d MoMdepth.%d\n",coin->symbol,height,MoMdepth); + //printf("done MoM calc %s height.%d MoMdepth.%d\n",coin->symbol,height,MoMdepth); return(MoM); } @@ -344,7 +344,7 @@ void dpow_statemachinestart(void *ptr) if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { bp = calloc(1,sizeof(*bp)); - printf("allocate bp for %s ht.%d -> %s\n",src->symbol,checkpoint.blockhash.height,dest->symbol); + //printf("allocate bp for %s ht.%d -> %s\n",src->symbol,checkpoint.blockhash.height,dest->symbol); Numallocated++; bp->MoM = MoM; bp->MoMdepth = MoMdepth; From 4b3af16b06e0f603b2966ede964ea8d910e6e240 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:43:48 +0200 Subject: [PATCH 10/17] Test --- iguana/dpow/dpow_fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 244bfb3a6..0386be3e2 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -287,7 +287,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu } ht = height - MoMdepth; } - if ( MoMdepth > 0 && MoMdepth < maxdepth ) + if ( MoMdepth > 0 ) { MoM = iguana_merkle(coin->symbol,merkles,MoMdepth); char str[65]; printf("%s from height.%d MoMdepth.%d -> MoM %s\n",coin->symbol,height,MoMdepth,bits256_str(str,MoM)); From 2f7ef7ef5f96aa100a4d2f0fbdc2efcc56ed7648 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:47:32 +0200 Subject: [PATCH 11/17] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- iguana/iguana_notary.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 0386be3e2..e3a742a00 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -262,10 +262,10 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( notht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) + if ( breakht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) { breakht = notht; - free_json(blockjson); + //free_json(blockjson); //printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 37c246b3f..f56bb4c79 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -95,7 +95,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( height > 0 && blocktime > 0 ) { dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); - if ( strcmp("BEER",dp->symbol) == 0 ) + if ( (0) &&strcmp("BEER",dp->symbol) == 0 ) printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height); checkpoint = dp->last; } else return; @@ -109,7 +109,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he printf("lastnotarized.(%s) is current checkpoint, skip\n",bits256_str(str,dp->lastnotarized)); return; } - if ( strcmp("BEER",dp->symbol) == 0 ) + if ( (0) && strcmp("BEER",dp->symbol) == 0 ) printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash)); } else return; } else return; @@ -118,7 +118,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he } if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 ) { - if ( strcmp("BEER",dp->symbol) == 0 ) + if ( (0) && strcmp("BEER",dp->symbol) == 0 ) printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000); ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t)); From c41a1b384056ba80ddfb233f49e473b50c71a630 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 00:47:51 +0200 Subject: [PATCH 12/17] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index e3a742a00..51f2f2af3 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -337,9 +337,9 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; - portable_mutex_lock(&myinfo->MoM_mutex); + //portable_mutex_lock(&myinfo->MoM_mutex); MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); - portable_mutex_unlock(&myinfo->MoM_mutex); + //portable_mutex_unlock(&myinfo->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { From a9191ce7b001fa6906292a632dcff746215a8e0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 01:01:23 +0200 Subject: [PATCH 13/17] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 51f2f2af3..5cf43414c 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -253,7 +253,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu free_json(blockjson); if ( bits256_nonz(merkle) != 0 ) { - merkles = calloc(maxdepth,sizeof(*merkles)); + merkles = calloc(maxdepth+1,sizeof(*merkles)); merkles[MoMdepth++] = merkle; ht = height - MoMdepth; while ( MoMdepth < maxdepth && ht >= breakht && ht > 0 ) @@ -290,7 +290,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu if ( MoMdepth > 0 ) { MoM = iguana_merkle(coin->symbol,merkles,MoMdepth); - char str[65]; printf("%s from height.%d MoMdepth.%d -> MoM %s\n",coin->symbol,height,MoMdepth,bits256_str(str,MoM)); + char str[65]; printf("%s from height.%d ht.%d MoMdepth.%d -> MoM %s\n",coin->symbol,height,ht,MoMdepth,bits256_str(str,MoM)); } else { From da1ae169e5780b3dca28b0b761bee1e35fd9d818 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 01:05:16 +0200 Subject: [PATCH 14/17] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 5cf43414c..59bf29330 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -337,9 +337,9 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; - //portable_mutex_lock(&myinfo->MoM_mutex); + portable_mutex_lock(&myinfo->MoM_mutex); MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); - //portable_mutex_unlock(&myinfo->MoM_mutex); + portable_mutex_unlock(&myinfo->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { From e787e617bebee0bde416ae1ed38b3859646ad9e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 01:13:42 +0200 Subject: [PATCH 15/17] Test --- iguana/dpow/dpow_fsm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 59bf29330..65898e260 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -262,7 +262,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( breakht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) + if ( (0) && breakht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) { breakht = notht; //free_json(blockjson); @@ -337,9 +337,9 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; - portable_mutex_lock(&myinfo->MoM_mutex); + //portable_mutex_lock(&myinfo->MoM_mutex); MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); - portable_mutex_unlock(&myinfo->MoM_mutex); + //portable_mutex_unlock(&myinfo->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { From 78ba8b64642d56738251263ae2f59a38a231a8aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 01:18:25 +0200 Subject: [PATCH 16/17] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 65898e260..18b2fd6ff 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -253,7 +253,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu free_json(blockjson); if ( bits256_nonz(merkle) != 0 ) { - merkles = calloc(maxdepth+1,sizeof(*merkles)); + merkles = calloc(3*maxdepth+1,sizeof(*merkles)); merkles[MoMdepth++] = merkle; ht = height - MoMdepth; while ( MoMdepth < maxdepth && ht >= breakht && ht > 0 ) @@ -262,7 +262,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( (0) && breakht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) + if ( breakht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) { breakht = notht; //free_json(blockjson); From fc4038af6c3775560e8074a71ad5a772867edca5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Mar 2018 01:22:02 +0200 Subject: [PATCH 17/17] Test --- iguana/dpow/dpow_fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 18b2fd6ff..48bec2e9c 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -243,7 +243,7 @@ int32_t dpow_hasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct iguana_info *coin,int32_t height) { - bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 256,MoMdepth = 0; + bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; int32_t breakht=0,notht=0,ht,maxdepth = 1440,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); //printf("start MoM calc %s height.%d\n",coin->symbol,height);