From cf843488635d61fc4f325ad4bbeb59dc91f3ad12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 4 Aug 2016 11:26:24 -0300 Subject: [PATCH] test --- iguana/iguana_init.c | 1 + iguana/iguana_recv.c | 2 ++ iguana/iguana_unspents.c | 7 +++---- iguana/main.c | 2 +- includes/iguana_structs.h | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 9c3614a81..b4e034b97 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -61,6 +61,7 @@ void iguana_initcoin(struct iguana_info *coin,cJSON *argjson) if ( coin->instance_nonce == 0 ) { sprintf(dirname,"%s/%s",GLOBAL_TMPDIR,coin->symbol), OS_portable_path(dirname); + portable_mutex_init(&coin->RTmutex); portable_mutex_init(&coin->peers_mutex); portable_mutex_init(&coin->blocks_mutex); coin->txfee = 10000; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 1d28c637f..d1dffdaf9 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1641,6 +1641,7 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin { int32_t i,newhwm = 0,hwmheight,flag = 0; char str[2000]; hwmheight = coin->blocks.hwmchain.height; + portable_mutex_lock(&coin->RTmutex); coin->RTramchain_busy = 1; if ( coin->balanceflush != 0 ) { @@ -1675,6 +1676,7 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin } } coin->RTramchain_busy = 0;//(coin->RTgenesis == 0); + portable_mutex_unlock(&coin->RTmutex); flag += iguana_process_msgrequestQ(myinfo,coin); //if ( strcmp("BTCD",coin->symbol) == 0 ) // instantdex_update(SuperNET_MYINFO(0)); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index da9ce8e8c..0f8e1452c 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -524,11 +524,9 @@ int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,int64_t *unspents,int32_t *numunspentsp,char *remoteaddr) { int64_t total=0,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,numunspents,maxunspents,flag = 0; char coinaddr[64]; - while ( coin->RTramchain_busy != 0 ) - { + portable_mutex_lock(&coin->RTmutex); + if ( coin->RTramchain_busy != 0 ) fprintf(stderr,"iguana_pkhasharray: unexpected access when RTramchain_busy\n"); - sleep(3); - } numunspents = 0; maxunspents = *numunspentsp; if ( rmdarray == 0 ) @@ -553,6 +551,7 @@ int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJ *numunspentsp = numunspents; if ( flag != 0 && rmdarray != 0 ) free(rmdarray); + portable_mutex_unlock(&coin->RTmutex); return(sum); } diff --git a/iguana/main.c b/iguana/main.c index 28328067a..48fc467a7 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -551,7 +551,7 @@ void iguana_appletests(struct supernet_info *myinfo) bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); getchar();**/ - if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index d8a7a2990..9d007bc94 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -401,7 +401,7 @@ struct iguana_info struct OS_memspace TXMEM,MEM,MEMB[IGUANA_MAXBUNDLESIZE]; queue_t acceptQ,hdrsQ,blocksQ,priorityQ,possibleQ,cacheQ,recvQ,msgrequestQ; double parsemillis,avetime; uint32_t Launched[8],Terminated[8]; - portable_mutex_t peers_mutex,blocks_mutex,special_mutex; + portable_mutex_t peers_mutex,blocks_mutex,special_mutex,RTmutex; char changeaddr[64]; struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending; struct iguana_ramchain RTramchain; struct OS_memspace RTmem,RThashmem; bits256 RThash1;