From 61703097afb3702a036db537a246aca99e295ba7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Jun 2017 17:38:14 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_network.c | 2 +- iguana/exchanges/LP_ordermatch.c | 2 +- iguana/exchanges/LP_utxos.c | 29 +++++++++++++++++++---------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 344f4c204..7fd4414b4 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -43,7 +43,7 @@ int32_t LP_send(int32_t sock,char *msg,int32_t freeflag) { if ( (sentbytes= nn_send(sock,msg,len,0)) != len ) printf("LP_send sent %d instead of %d\n",sentbytes,len); - else printf("SENT.(%s)\n",msg); + //else printf("SENT.(%s)\n",msg); if ( freeflag != 0 ) free(msg); return(sentbytes); diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index fed378733..d65519218 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -560,7 +560,7 @@ char *LP_autotrade(char *myipaddr,int32_t mypubsock,double profitmargin,char *ba { if ( bestprice == 0. ) // assumes price ordered asks bestprice = price; - printf("item.[%d] %s\n",i,jprint(item,0)); + //printf("item.[%d] %s\n",i,jprint(item,0)); txid = jbits256(item,"txid"); vout = jint(item,"vout"); vol = jdouble(item,"volume"); diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index bd0d53970..f1aa59266 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -114,19 +114,25 @@ int32_t LP_utxocollisions(struct LP_utxoinfo *ptrs[],struct LP_utxoinfo *refutxo n = LP_utxoaddptrs(ptrs,n,utxo); } portable_mutex_unlock(&LP_utxomutex); - if ( n > 0 ) + if ( 0 && n > 0 ) printf("LP_utxocollisions n.%d\n",n); return(n); } -void _LP_availableset(struct LP_utxoinfo *utxo) +int32_t _LP_availableset(struct LP_utxoinfo *utxo) { + int32_t flag = 0; if ( utxo != 0 ) { - memset(&utxo->S.otherpubkey,0,sizeof(utxo->S.otherpubkey)); - utxo->S.swap = 0; - utxo->T.swappending = 0; + if ( bits256_nonz(utxo->S.otherpubkey) != 0 ) + flag = 1, memset(&utxo->S.otherpubkey,0,sizeof(utxo->S.otherpubkey)); + if ( utxo->S.swap != 0 ) + flag = 1, utxo->S.swap = 0; + if ( utxo->T.swappending != 0 ) + flag = 1, utxo->T.swappending = 0; + return(flag); } + return(0); } void _LP_unavailableset(struct LP_utxoinfo *utxo,bits256 otherpubkey) @@ -154,16 +160,19 @@ void LP_unavailableset(struct LP_utxoinfo *utxo,bits256 otherpubkey) void LP_availableset(struct LP_utxoinfo *utxo) { - struct LP_utxoinfo *ptrs[8]; int32_t i,n; struct _LP_utxoinfo u; + struct LP_utxoinfo *ptrs[8]; int32_t i,n,count = 0; struct _LP_utxoinfo u; memset(ptrs,0,sizeof(ptrs)); if ( (n= LP_utxocollisions(ptrs,utxo)) > 0 ) { for (i=0; i 0 ) + { + u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; + char str[65],str2[65]; printf("UTXO.[%d] AVAIL %s/v%d %s/v%d collisions.%d\n",utxo->iambob,bits256_str(str,utxo->payment.txid),utxo->payment.vout,bits256_str(str2,u.txid),u.vout,n); } - u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; - char str[65],str2[65]; printf("UTXO.[%d] AVAIL %s/v%d %s/v%d collisions.%d\n",utxo->iambob,bits256_str(str,utxo->payment.txid),utxo->payment.vout,bits256_str(str2,u.txid),u.vout,n); - _LP_availableset(utxo); } int32_t LP_utxopurge(int32_t allutxos)