diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index be84416ad..6f0b1d76d 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -243,6 +243,7 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata) //printf("%s: (%s) (%s)\n",symbol,cdata.serverport,cdata.userpass); *coin = *cdata; portable_mutex_init(&coin->txmutex); + portable_mutex_init(&coin->addrmutex); portable_mutex_lock(&LP_coinmutex); HASH_ADD_KEYPTR(hh,LP_coins,coin->symbol,strlen(coin->symbol),coin); portable_mutex_unlock(&LP_coinmutex); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 50117b1b8..fe016e027 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -179,7 +179,7 @@ struct LP_transaction struct iguana_info { UT_hash_handle hh; - portable_mutex_t txmutex; struct LP_transaction *transactions; struct LP_address *addresses; + portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses; uint64_t txfee; int32_t longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport; uint32_t counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,unspenttime; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 12fdbf2b0..da09bfff5 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -429,7 +429,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int continue; if ( time(NULL) > coin->lastmonitor+60 ) { - portable_mutex_lock(&coin->txmutex); + portable_mutex_lock(&coin->addrmutex); HASH_ITER(hh,coin->addresses,ap,atmp) { if ( coin->electrum == 0 ) @@ -449,7 +449,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int free_json(retjson); } } - portable_mutex_unlock(&coin->txmutex); + portable_mutex_unlock(&coin->addrmutex); coin->lastmonitor = (uint32_t)time(NULL); } if ( coin->electrum != 0 ) diff --git a/iguana/exchanges/LP_scan.c b/iguana/exchanges/LP_scan.c index ddd95f458..5f0b4175b 100644 --- a/iguana/exchanges/LP_scan.c +++ b/iguana/exchanges/LP_scan.c @@ -184,6 +184,7 @@ cJSON *LP_snapshot(struct iguana_info *coin,int32_t height) } } portable_mutex_lock(&coin->txmutex); + portable_mutex_lock(&coin->addrmutex); HASH_ITER(hh,coin->addresses,ap,atmp) { ap->balance = 0; @@ -220,6 +221,7 @@ cJSON *LP_snapshot(struct iguana_info *coin,int32_t height) } } HASH_SORT(coin->addresses,sort_balance); + portable_mutex_unlock(&coin->addrmutex); portable_mutex_unlock(&coin->txmutex); printf("%s balance %.8f at height.%d\n",coin->symbol,dstr(balance),height); array = cJSON_CreateArray(); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index da4b15b63..23486304a 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -90,16 +90,16 @@ struct LP_address *_LP_address(struct iguana_info *coin,char *coinaddr) struct LP_address *LP_addressfind(struct iguana_info *coin,char *coinaddr) { struct LP_address *ap; - portable_mutex_lock(&coin->txmutex); + portable_mutex_lock(&coin->addrmutex); ap = _LP_addressfind(coin,coinaddr); - portable_mutex_unlock(&coin->txmutex); + portable_mutex_unlock(&coin->addrmutex); return(ap); } int32_t LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight) { struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t flag,retval = 0; - printf("%s add addr.%s ht.%d\n",coin->symbol,coinaddr,height); + //printf("%s add addr.%s ht.%d\n",coin->symbol,coinaddr,height); if ( (ap= _LP_address(coin,coinaddr)) != 0 ) { flag = 0; @@ -123,16 +123,16 @@ int32_t LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid, up->U.height = height; up->U.value = value; up->spendheight = spendheight; - portable_mutex_lock(&coin->txmutex); + portable_mutex_lock(&coin->addrmutex); DL_APPEND(ap->utxos,up); - portable_mutex_unlock(&coin->txmutex); + portable_mutex_unlock(&coin->addrmutex); retval = 1; char str[65]; if ( height > 0 ) printf(">>>>>>>>>> %s %s %s/v%d ht.%d %.8f\n",coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value)); } } - printf("done %s add addr.%s ht.%d\n",coin->symbol,coinaddr,height); + //printf("done %s add addr.%s ht.%d\n",coin->symbol,coinaddr,height); return(retval); } @@ -163,7 +163,7 @@ cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrum array = cJSON_CreateArray(); if ( coinaddr != 0 && coinaddr[0] != 0 ) { - portable_mutex_lock(&coin->txmutex); + portable_mutex_lock(&coin->addrmutex); if ( (ap= _LP_addressfind(coin,coinaddr)) != 0 ) { DL_FOREACH_SAFE(ap->utxos,up,tmp) @@ -176,7 +176,7 @@ cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrum } } } - portable_mutex_unlock(&coin->txmutex); + portable_mutex_unlock(&coin->addrmutex); } //printf("%s %s utxos.(%s) ap.%p\n",coin->symbol,coinaddr,jprint(array,0),ap); return(array); @@ -256,12 +256,12 @@ char *LP_postedutxos(cJSON *argjson) HASH_ITER(hh,LP_coins,coin,tmp) { bitcoin_address(coinaddr,coin->taddr,coin->pubtype,pubp->rmd160,sizeof(pubp->rmd160)); - portable_mutex_lock(&coin->txmutex); + portable_mutex_lock(&coin->addrmutex); if ( (ap= _LP_address(coin,coinaddr)) != 0 ) { ap->monitor = (uint32_t)time(NULL); } - portable_mutex_unlock(&coin->txmutex); + portable_mutex_unlock(&coin->addrmutex); if ( coin->electrum != 0 ) { if ( (retjson= electrum_address_subscribe(coin->symbol,coin->electrum,&retjson,coinaddr)) != 0 )