jl777 8 years ago
parent
commit
3c7d8fe6e7
  1. 1
      iguana/exchanges/LP_nativeDEX.c
  2. 10
      iguana/exchanges/LP_prices.c
  3. 25
      iguana/exchanges/LP_utxo.c

1
iguana/exchanges/LP_nativeDEX.c

@ -437,6 +437,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int
{
if ( coin->electrum == 0 )
{
// issue listunspent
DL_FOREACH_SAFE(ap->utxos,up,utmp)
{
if ( up->spendheight <= 0 )

10
iguana/exchanges/LP_prices.c

@ -649,7 +649,11 @@ int32_t LP_orderbook_utxoentries(uint32_t now,int32_t polarity,char *base,char *
char *LP_orderbook(char *base,char *rel,int32_t duration)
{
uint32_t now,i; struct LP_priceinfo *basepp=0,*relpp=0; struct LP_orderbookentry **bids = 0,**asks = 0; cJSON *retjson,*array; int32_t numbids=0,numasks=0,cachenumbids,cachenumasks,baseid,relid;
uint32_t now,i; struct LP_priceinfo *basepp=0,*relpp=0; struct LP_orderbookentry **bids = 0,**asks = 0; cJSON *retjson,*array; struct iguana_info *basecoin,*relcoin; int32_t numbids=0,numasks=0,cachenumbids,cachenumasks,baseid,relid;
basecoin = LP_coinfind(base);
relcoin = LP_coinfind(rel);
if ( basecoin == 0 || relcoin == 0 )
return(clonestr("{\"error\":\"base or rel not added\"}"));
if ( (basepp= LP_priceinfofind(base)) == 0 || (relpp= LP_priceinfofind(rel)) == 0 )
return(clonestr("{\"error\":\"base or rel not added\"}"));
if ( duration <= 0 )
@ -679,7 +683,7 @@ char *LP_orderbook(char *base,char *rel,int32_t duration)
{
jaddi(array,LP_orderbookjson(rel,bids[i]));
if ( i < 3 )
LP_check_unspents(rel,bids[i]);
LP_address(relcoin,bids[i]->coinaddr);
free(bids[i]);
bids[i] = 0;
}
@ -690,7 +694,7 @@ char *LP_orderbook(char *base,char *rel,int32_t duration)
{
jaddi(array,LP_orderbookjson(base,asks[i]));
if ( i < 3 )
LP_check_unspents(base,asks[i]);
LP_address(basecoin,asks[i]->coinaddr);
free(asks[i]);
asks[i] = 0;
}

25
iguana/exchanges/LP_utxo.c

@ -81,7 +81,7 @@ struct LP_address *_LP_addressadd(struct iguana_info *coin,char *coinaddr)
struct LP_address *_LP_address(struct iguana_info *coin,char *coinaddr)
{
struct LP_address *ap;
struct LP_address *ap = 0;
if ( (ap= _LP_addressfind(coin,coinaddr)) == 0 )
ap = _LP_addressadd(coin,coinaddr);
return(ap);
@ -89,10 +89,25 @@ 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->addrmutex);
ap = _LP_addressfind(coin,coinaddr);
portable_mutex_unlock(&coin->addrmutex);
struct LP_address *ap = 0;
if ( coin != 0 )
{
portable_mutex_lock(&coin->addrmutex);
ap = _LP_addressfind(coin,coinaddr);
portable_mutex_unlock(&coin->addrmutex);
}
return(ap);
}
struct LP_address *LP_address(struct iguana_info *coin,char *coinaddr)
{
struct LP_address *ap = 0;
if ( coin != 0 )
{
portable_mutex_lock(&coin->addrmutex);
ap = _LP_address(coin,coinaddr);
portable_mutex_unlock(&coin->addrmutex);
}
return(ap);
}

Loading…
Cancel
Save