From 7329aadd75688271997642dfe4691efd1c6ab307 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Aug 2016 12:57:44 -0300 Subject: [PATCH] test --- iguana/iguana_volatiles.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_volatiles.c b/iguana/iguana_volatiles.c index e553a77f7..23b1cfd0b 100755 --- a/iguana/iguana_volatiles.c +++ b/iguana/iguana_volatiles.c @@ -83,7 +83,7 @@ int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t *RTspendflagp,int32_t lockflag) { - uint64_t val,uval; struct iguana_hhutxo *hhutxo; struct iguana_utxo utxo; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; + uint64_t val,uval; struct iguana_hhutxo *hhutxo; struct iguana_utxo utxo; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t flag; *RTspendflagp = 0; memset(&utxo,0,sizeof(utxo)); if ( (bp= coin->bundles[spent_hdrsi]) == 0 ) @@ -91,7 +91,9 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi, ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) == 0 ) return(utxo); - portable_mutex_lock(&coin->RTmutex); + flag = (coin->RTheight > 0); + if ( flag != 0 ) + portable_mutex_lock(&coin->RTmutex); val = ((uint64_t)spent_hdrsi << 32) | spent_unspentind; if ( spent_unspentind > 0 && spent_unspentind < rdata->numunspents ) { @@ -107,7 +109,8 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi, { printf("iguana_hhutxofind warning: hhutxo.%p spentflag.%d\n",hhutxo,hhutxo->u.spentflag); memset(&utxo,0,sizeof(utxo)); - portable_mutex_unlock(&coin->RTmutex); + if ( flag != 0 ) + portable_mutex_unlock(&coin->RTmutex); return(utxo); } hhutxo = calloc(1,sizeof(*hhutxo)); @@ -137,7 +140,8 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi, { printf("illegal unspentind.%u vs %u hdrs.%d\n",spent_unspentind,rdata->numunspents,spent_hdrsi); } - portable_mutex_unlock(&coin->RTmutex); + if ( flag != 0 ) + portable_mutex_unlock(&coin->RTmutex); return(utxo); }