Browse Source

Merge pull request #475 from jl777/spvdex

fix dustcombine bug and mark as inuse
etomic
jl777 7 years ago
committed by GitHub
parent
commit
f9e627486e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      iguana/exchanges/LP_nativeDEX.c
  2. 3
      iguana/exchanges/LP_transaction.c
  3. 28
      iguana/exchanges/LP_utxo.c

8
iguana/exchanges/LP_nativeDEX.c

@ -17,7 +17,10 @@
// LP_nativeDEX.c
// marketmaker
//
// single utxo allocations alice, reject result, latency
// single utxo allocations alice
// gc cJSON
// more retries for swap sendrawtransaction
// pbca26 unfinished swaps
// alice waiting for bestprice
//if ( G.LP_pendingswaps != 0 )
//return(-1);
@ -179,7 +182,6 @@ char *LP_command_process(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson
char *retstr=0;
if ( jobj(argjson,"result") != 0 || jobj(argjson,"error") != 0 )
return(0);
//double millis = OS_milliseconds();
if ( LP_tradecommand(ctx,myipaddr,pubsock,argjson,data,datalen) <= 0 )
{
if ( (retstr= stats_JSON(ctx,myipaddr,pubsock,argjson,"127.0.0.1",0)) != 0 )
@ -189,8 +191,6 @@ char *LP_command_process(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson
//LP_send(pubsock,retstr,(int32_t)strlen(retstr)+1,0);
}
} //else printf("finished tradecommand (%s)\n",jprint(argjson,0));
//if ( OS_milliseconds()-millis > 100 )
// printf("%.3f %s\n",OS_milliseconds()-millis,jprint(argjson,0));
return(retstr);
}

3
iguana/exchanges/LP_transaction.c

@ -987,6 +987,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
vp->suppress_pubkeys = suppress_pubkeys;
vp->ignore_cltverr = ignore_cltverr;
jaddi(vins,LP_inputjson(up->U.txid,up->U.vout,spendscriptstr));
LP_unavailableset(up->U.txid,up->U.vout,(uint32_t)time(NULL)+600,G.LP_mypub25519);
if ( remains <= 0 && i >= numpre-1 )
break;
if ( numunspents < 0 )
@ -1019,7 +1020,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf
}
if ( coin->numutxos < LP_MINDESIRED_UTXOS )
dustcombine = 0;
else if ( coin->numutxos >= LP_MINDESIRED_UTXOS )
else if ( coin->numutxos >= LP_MAXDESIRED_UTXOS )
dustcombine = 2;
else dustcombine = 1;
amount = txfee;

28
iguana/exchanges/LP_utxo.c

@ -58,8 +58,32 @@ int32_t _LP_inuse_delete(bits256 txid,int32_t vout)
struct LP_inuse_info *_LP_inuse_add(uint32_t expiration,bits256 otherpub,bits256 txid,int32_t vout)
{
struct LP_inuse_info *lp;
if ( bits256_nonz(txid) != 0 && LP_numinuse < sizeof(LP_inuse)/sizeof(*LP_inuse) )
struct LP_inuse_info *lp; int32_t i,n,oldesti; uint32_t now,oldest;
if ( LP_numinuse >= sizeof(LP_inuse)/sizeof(*LP_inuse) )
{
now = (uint32_t)time(NULL);
n = 0;
oldesti = -1;
oldest = 0;
for (i=0; i<sizeof(LP_inuse)/sizeof(*LP_inuse); i++)
{
lp = &LP_inuse[i];
if ( now > lp->expiration )
_LP_inuse_delete(lp->txid,lp->vout), n++;
else if ( oldest == 0 || lp->expiration < oldest )
{
oldest = lp->expiration;
oldesti = i;
}
}
if ( n == 0 )
{
printf("_LP_inuse_add out of slots error, pick oldesti %d\n",oldesti);
lp = &LP_inuse[oldesti];
_LP_inuse_delete(lp->txid,lp->vout);
} else printf("expired %d inuse slots\n",n);
}
if ( bits256_nonz(txid) != 0 )
{
if ( (lp= _LP_inuse_find(txid,vout)) == 0 )
{

Loading…
Cancel
Save