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);