From af148d931ab197dc7ba6d27dc9767af6e3283e3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 11 Nov 2017 22:09:35 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_prices.c | 22 +++++++++++++--------- iguana/exchanges/LP_socket.c | 9 ++------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 868975735..66bb2fdc3 100644 --- a/iguana/exchanges/LP_prices.c +++ b/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; inumutxos < 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; inumutxos < 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]); diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 6890371db..5be93ba33 100644 --- a/iguana/exchanges/LP_socket.c +++ b/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 )