From 70fcf731b96f18e5a963102a17b124681b338bd3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 14 Jun 2017 14:17:48 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_prices.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index b15d521c4..b026dcd47 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -369,22 +369,22 @@ int32_t LP_orderbookfind(struct LP_orderbookentry **array,int32_t num,bits256 tx return(-1); } -int32_t LP_orderbook_utxoentries(uint32_t now,char *base,char *rel,char *symbol,double price,struct LP_orderbookentry **array,int32_t num,int32_t cachednum,bits256 pubkey) +int32_t LP_orderbook_utxoentries(uint32_t now,char *base,char *rel,char *symbol,double price,struct LP_orderbookentry *(**arrayp),int32_t num,int32_t cachednum,bits256 pubkey) { struct LP_utxoinfo *utxo,*tmp; struct LP_peerinfo *peer,*ptmp; char *retstr; cJSON *retjson; struct LP_orderbookentry *op; uint64_t basesatoshis; HASH_ITER(hh,LP_utxoinfos[1],utxo,tmp) { if ( LP_ismine(utxo) > 0 && strcmp(symbol,utxo->coin) == 0 && LP_isavailable(utxo) > 0 ) { - if ( LP_orderbookfind(array,cachednum,utxo->payment.txid,utxo->payment.vout) < 0 ) + if ( LP_orderbookfind(*arrayp,cachednum,utxo->payment.txid,utxo->payment.vout) < 0 ) { char str[65]; printf("found utxo not in orderbook %s/v%d\n",bits256_str(str,utxo->payment.txid),utxo->payment.vout); - array = realloc(array,sizeof(*array) * (num+1)); + *arrayp = realloc(*arrayp,sizeof(*(*arrayp)) * (num+1)); if ( strcmp(base,symbol) == 0 ) basesatoshis = utxo->payment.value; else basesatoshis = utxo->payment.value * price; if ( (op= LP_orderbookentry(base,rel,utxo->payment.txid,utxo->payment.vout,price,basesatoshis)) != 0 ) - array[num++] = op; + (*arrayp)[num++] = op; if ( bits256_cmp(utxo->pubkey,LP_mypubkey) == 0 && utxo->T.lasttime == 0 ) { HASH_ITER(hh,LP_peerinfos,peer,ptmp) @@ -438,9 +438,10 @@ char *LP_orderbook(char *base,char *rel) HASH_ITER(hh,LP_pubkeyinfos,pubp,ptmp) { if ( pubp->matrix[baseid][relid] > SMALLVAL ) - numasks = LP_orderbook_utxoentries(now,base,rel,base,pubp->matrix[baseid][relid],asks,numasks,cachenumasks,pubp->pubkey); + numasks = LP_orderbook_utxoentries(now,base,rel,base,pubp->matrix[baseid][relid],&asks,numasks,cachenumasks,pubp->pubkey); if ( pubp->matrix[relid][baseid] > SMALLVAL ) - numbids = LP_orderbook_utxoentries(now,base,rel,rel,pubp->matrix[relid][baseid],bids,numbids,cachenumbids,pubp->pubkey); + numbids = LP_orderbook_utxoentries(now,base,rel,rel,pubp->matrix[relid][baseid],&bids,numbids,cachenumbids,pubp->pubkey); + printf("cache.(%d %d) numbids.%d numasks.%d\n",cachenumbids,cachenumasks,numbids,numasks); } retjson = cJSON_CreateObject(); array = cJSON_CreateArray();