Browse Source

Test

etomic
jl777 7 years ago
parent
commit
af148d931a
  1. 22
      iguana/exchanges/LP_prices.c
  2. 9
      iguana/exchanges/LP_socket.c

22
iguana/exchanges/LP_prices.c

@ -765,7 +765,7 @@ 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; uint64_t depth; struct LP_priceinfo *basepp=0,*relpp=0; struct LP_orderbookentry **bids = 0,**asks = 0; cJSON *retjson,*tmpjson,*array; struct iguana_info *basecoin,*relcoin; int32_t n,numbids=0,numasks=0,cachenumbids,cachenumasks,baseid,relid,suppress_prefetch=0;
uint32_t now,i; uint64_t depth; struct LP_priceinfo *basepp=0,*relpp=0; struct LP_orderbookentry **bids = 0,**asks = 0; cJSON *retjson,*array; struct iguana_info *basecoin,*relcoin; int32_t n,numbids=0,numasks=0,cachenumbids,cachenumasks,baseid,relid,suppress_prefetch=0;
basecoin = LP_coinfind(base);
relcoin = LP_coinfind(rel);
if ( basecoin == 0 || relcoin == 0 )
@ -813,15 +813,17 @@ char *LP_orderbook(char *base,char *rel,int32_t duration)
for (i=n=0; i<numbids; i++)
{
jaddi(array,LP_orderbookjson(rel,bids[i]));
if ( suppress_prefetch == 0 && n < 7 && bids[i]->numutxos < 3 )
if ( suppress_prefetch == 0 && n < 3 && bids[i]->numutxos == 0 )
{
//printf("bid ping %s %s\n",rel,bids[i]->coinaddr);
LP_address(relcoin,bids[i]->coinaddr);
if ( relcoin->electrum == 0 )
{
LP_listunspent_issue(rel,bids[i]->coinaddr,0);
else if ( (tmpjson= LP_listunspent(rel,bids[i]->coinaddr)) != 0 )
free_json(tmpjson);
LP_listunspent_query(rel,bids[i]->coinaddr);
//else if ( (tmpjson= LP_listunspent(rel,bids[i]->coinaddr)) != 0 )
// free_json(tmpjson);
LP_listunspent_query(rel,bids[i]->coinaddr);
}
n++;
}
free(bids[i]);
@ -835,15 +837,17 @@ char *LP_orderbook(char *base,char *rel,int32_t duration)
for (i=n=0; i<numasks; i++)
{
jaddi(array,LP_orderbookjson(base,asks[i]));
if ( suppress_prefetch == 0 && n < 7 && asks[i]->numutxos < 3 )
if ( suppress_prefetch == 0 && n < 3 && asks[i]->numutxos == 0 )
{
//printf("ask ping %s %s\n",base,asks[i]->coinaddr);
LP_address(basecoin,asks[i]->coinaddr);
if ( basecoin->electrum == 0 )
{
LP_listunspent_issue(base,asks[i]->coinaddr,0);
else if ( (tmpjson= LP_listunspent(base,asks[i]->coinaddr)) != 0 )
free_json(tmpjson);
LP_listunspent_query(base,asks[i]->coinaddr);
//else if ( (tmpjson= LP_listunspent(base,asks[i]->coinaddr)) != 0 )
// free_json(tmpjson);
LP_listunspent_query(base,asks[i]->coinaddr);
}
n++;
}
free(asks[i]);

9
iguana/exchanges/LP_socket.c

@ -420,16 +420,11 @@ cJSON *electrum_submit(char *symbol,struct electrum_info *ep,cJSON **retjsonp,ch
//printf("%s %s",symbol,stratumreq);
memset(ep->buf,0,ep->bufsize);
sitem = electrum_sitem(ep,stratumreq,timeout,retjsonp);
/*sitem = (struct stritem *)queueitem(stratumreq);
sitem->expiration = timeout;
sitem->DL.type = ep->stratumid++;
sitem->retptrp = (void **)retjsonp;*/
portable_mutex_lock(&ep->mutex);
//queue_enqueue("sendQ",&ep->sendQ,&sitem->DL);
portable_mutex_lock(&ep->mutex); // this helps performance!
expiration = (uint32_t)time(NULL) + timeout + 1;
while ( *retjsonp == 0 && time(NULL) <= expiration )
usleep(15000);
portable_mutex_unlock(&ep->mutex);
portable_mutex_unlock(&ep->mutex);
if ( *retjsonp == 0 || jobj(*retjsonp,"error") != 0 )
{
if ( ++ep->numerrors >= LP_ELECTRUM_MAXERRORS )

Loading…
Cancel
Save