From 1c41483cc8b6855bfc1112b7ce0e542f25f21ad8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Jun 2017 19:45:26 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_utxos.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index a0bd6bb8f..7b5f63556 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -43,8 +43,17 @@ struct LP_utxoinfo *LP_utxofind(bits256 txid,int32_t vout) memcpy(&key[sizeof(txid)],&vout,sizeof(vout)); portable_mutex_lock(&LP_utxomutex); HASH_FIND(hh,LP_utxoinfos,key,sizeof(key),utxo); - if ( utxo == 0 ) - HASH_FIND(hh,LP_utxoinfos2,key,sizeof(key),utxo); + portable_mutex_unlock(&LP_utxomutex); + return(utxo); +} + +struct LP_utxoinfo *LP_utxo2find(bits256 txid,int32_t vout) +{ + struct LP_utxoinfo *utxo=0; uint8_t key[sizeof(txid) + sizeof(vout)]; + memcpy(key,txid.bytes,sizeof(txid)); + memcpy(&key[sizeof(txid)],&vout,sizeof(vout)); + portable_mutex_lock(&LP_utxomutex); + HASH_FIND(hh,LP_utxoinfos2,key,sizeof(key),utxo); portable_mutex_unlock(&LP_utxomutex); return(utxo); } @@ -221,7 +230,8 @@ struct LP_utxoinfo *LP_addutxo(int32_t amclient,struct LP_peerinfo *mypeer,int32 memcpy(&utxo->key2[sizeof(txid2)],&vout2,sizeof(vout2)); portable_mutex_lock(&LP_utxomutex); HASH_ADD_KEYPTR(hh,LP_utxoinfos,utxo->key,sizeof(utxo->key),utxo); - HASH_ADD_KEYPTR(hh,LP_utxoinfos2,utxo->key2,sizeof(utxo->key2),utxo); + if ( LP_utxo2find(txid2,vout2) == 0 ) + HASH_ADD_KEYPTR(hh,LP_utxoinfos2,utxo->key2,sizeof(utxo->key2),utxo); if ( mypeer != 0 ) mypeer->numutxos++; portable_mutex_unlock(&LP_utxomutex);