Browse Source

Test

etomic
jl777 7 years ago
parent
commit
c68105dbe2
  1. 1
      iguana/exchanges/LP_include.h
  2. 17
      iguana/exchanges/LP_prices.c
  3. 6
      iguana/exchanges/LP_stats.c

1
iguana/exchanges/LP_include.h

@ -398,6 +398,7 @@ struct LP_pubkey_info
bits256 pubkey;
struct LP_pubkey_quote *quotes;
struct LP_pubswap *bobswaps,*aliceswaps;
uint64_t dynamictrust;
uint32_t timestamp,numerrors,lasttime;
int32_t istrusted;
uint8_t rmd160[20],sig[65],pubsecp[33],siglen;

17
iguana/exchanges/LP_prices.c

@ -18,7 +18,15 @@
// marketmaker
//
struct LP_orderbookentry { bits256 pubkey; double price; uint64_t avesatoshis,maxsatoshis,depth; uint32_t timestamp; int32_t numutxos; char coinaddr[64]; };
struct LP_orderbookentry
{
bits256 pubkey;
double price;
uint64_t avesatoshis,maxsatoshis,depth,dynamictrust;
uint32_t timestamp;
int32_t numutxos;
char coinaddr[64];
};
struct LP_priceinfo
{
@ -750,12 +758,12 @@ cJSON *LP_orderbookjson(char *symbol,struct LP_orderbookentry *op)
jaddnum(item,"depth",dstr(op->depth)*0.8);
jaddbits256(item,"pubkey",op->pubkey);
jaddnum(item,"age",time(NULL)-op->timestamp);
jaddnum(item,"zcredits",dstr(LP_dynamictrust(op->pubkey,0)));
jaddnum(item,"zcredits",dstr(op->dynamictrust));
}
return(item);
}
struct LP_orderbookentry *LP_orderbookentry(char *address,char *base,char *rel,double price,int32_t numutxos,uint64_t avesatoshis,uint64_t maxsatoshis,bits256 pubkey,uint32_t timestamp,uint64_t balance)
struct LP_orderbookentry *LP_orderbookentry(char *address,char *base,char *rel,double price,int32_t numutxos,uint64_t avesatoshis,uint64_t maxsatoshis,bits256 pubkey,uint32_t timestamp,uint64_t balance,uint64_t dynamictrust)
{
struct LP_orderbookentry *op;
if ( (op= calloc(1,sizeof(*op))) != 0 )
@ -768,6 +776,7 @@ struct LP_orderbookentry *LP_orderbookentry(char *address,char *base,char *rel,d
op->pubkey = pubkey;
op->timestamp = timestamp;
op->depth = balance;
op->dynamictrust = dynamictrust;
}
return(op);
}
@ -828,7 +837,7 @@ int32_t LP_orderbook_utxoentries(uint32_t now,int32_t polarity,char *base,char *
}
//printf("%s/%s %s n.%d ap->n.%d %.8f\n",base,rel,coinaddr,n,ap->n,dstr(ap->total));
}
if ( (op= LP_orderbookentry(coinaddr,base,rel,polarity > 0 ? price : 1./price,n,avesatoshis,maxsatoshis,pubp->pubkey,pubp->timestamp,balance)) != 0 )
if ( (op= LP_orderbookentry(coinaddr,base,rel,polarity > 0 ? price : 1./price,n,avesatoshis,maxsatoshis,pubp->pubkey,pubp->timestamp,balance,pubp->dynamictrust)) != 0 )
{
*arrayp = realloc(*arrayp,sizeof(*(*arrayp)) * (num+1));
(*arrayp)[num++] = op;

6
iguana/exchanges/LP_stats.c

@ -428,7 +428,7 @@ int32_t LP_stats_dispiter(cJSON *array,struct LP_swapstats *sp,uint32_t starttim
cJSON *LP_statslog_disp(uint32_t starttime,uint32_t endtime,char *refgui,bits256 refpubkey,char *refbase,char *refrel)
{
static int32_t rval;
cJSON *retjson,*array,*item,*reqjson; bits256 zero; uint32_t now; struct LP_swapstats *sp,*tmp; int32_t i,n,numtrades[LP_MAXPRICEINFOS]; uint64_t basevols[LP_MAXPRICEINFOS],relvols[LP_MAXPRICEINFOS];
cJSON *retjson,*array,*item,*reqjson; struct LP_pubkey_info *pubp,*ptmp; bits256 zero; uint32_t now; struct LP_swapstats *sp,*tmp; int32_t i,n,numtrades[LP_MAXPRICEINFOS]; uint64_t basevols[LP_MAXPRICEINFOS],relvols[LP_MAXPRICEINFOS];
if ( rval == 0 )
rval = (LP_rand() % 300) + 60;
if ( starttime > endtime )
@ -468,6 +468,10 @@ cJSON *LP_statslog_disp(uint32_t starttime,uint32_t endtime,char *refgui,bits256
LP_stats_dispiter(array,sp,starttime,endtime,refbase,refrel,refgui,refpubkey);
LP_swapscount++;
}
HASH_ITER(hh,LP_pubkeyinfos,pubp,ptmp)
{
pubp->dynamictrust = LP_dynamictrust(pubp->pubkey,0);
}
//printf("RT.%d completed.%d\n",LP_RTcount,LP_swapscount);
jadd(retjson,"swaps",array);
jaddnum(retjson,"RTcount",LP_RTcount);

Loading…
Cancel
Save