Browse Source

Test

etomic
jl777 7 years ago
parent
commit
95808a433c
  1. 18
      iguana/exchanges/LP_prices.c
  2. 10
      iguana/exchanges/LP_utxos.c

18
iguana/exchanges/LP_prices.c

@ -52,6 +52,7 @@ struct LP_pubkeyinfo
bits256 pubkey;
double matrix[LP_MAXPRICEINFOS][LP_MAXPRICEINFOS];
uint32_t timestamp,istrusted,numerrors;
uint8_t rmd160[20];
} *LP_pubkeyinfos;
int32_t LP_pricevalid(double price)
@ -171,7 +172,7 @@ char *LP_pubkey_trustset(bits256 pubkey,uint32_t trustval)
cJSON *LP_pubkeyjson(struct LP_pubkeyinfo *pubp)
{
int32_t baseid,relid; char *base; double price; cJSON *item,*array,*obj;
int32_t baseid,relid; char *base,hexstr[41]; double price; cJSON *item,*array,*obj;
obj = cJSON_CreateObject();
array = cJSON_CreateArray();
for (baseid=0; baseid<LP_numpriceinfos; baseid++)
@ -191,6 +192,8 @@ cJSON *LP_pubkeyjson(struct LP_pubkeyinfo *pubp)
}
}
jaddbits256(obj,"pubkey",pubp->pubkey);
init_hexbytes_noT(hexstr,pubp->rmd160,sizeof(pubp->rmd160));
jaddstr(obj,"rmd160",hexstr);
jaddnum(obj,"timestamp",pubp->timestamp);
jadd(obj,"asks",array);
if ( pubp->istrusted != 0 )
@ -210,10 +213,21 @@ char *LP_prices()
void LP_prices_parse(cJSON *obj)
{
struct LP_pubkeyinfo *pubp; struct LP_priceinfo *basepp,*relpp; uint32_t timestamp; bits256 pubkey; cJSON *asks,*item; int32_t i,n,relid; char *base,*rel; double askprice;
struct LP_pubkeyinfo *pubp; struct LP_priceinfo *basepp,*relpp; uint32_t timestamp; bits256 pubkey; cJSON *asks,*item; uint8_t rmd160[20]; int32_t i,n,relid; char *base,*rel,*hexstr; double askprice;
pubkey = jbits256(obj,"pubkey");
if ( bits256_nonz(pubkey) != 0 && (pubp= LP_pubkeyadd(pubkey)) != 0 )
{
if ( (hexstr= jstr(obj,"rmd160")) != 0 && strlen(hexstr) == 2*sizeof(rmd160) )
{
decode_hex(rmd160,sizeof(rmd160),hexstr);
if ( memcmp(pubp->rmd160,rmd160,sizeof(rmd160)) != 0 )
{
for (i=0; i<20; i++)
printf("%02x",pubp->rmd160[i]);
char str[65]; printf(" -> rmd160.(%s) for %s\n",hexstr,bits256_str(str,pubkey));
memcpy(pubp->rmd160,rmd160,sizeof(pubp->rmd160));
}
}
if ( (timestamp= juint(obj,"timestamp")) > pubp->timestamp && (asks= jarray(&n,obj,"asks")) != 0 )
{
pubp->timestamp = timestamp;

10
iguana/exchanges/LP_utxos.c

@ -567,11 +567,6 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,int32_t mypubsock,char *symbol,bit
if ( dispflag != 0 )
printf("%.8f %.8f %s iambob.%d %s utxoadd.(%.8f %.8f) %s %s\n",dstr(val),dstr(val2),coinaddr,iambob,symbol,dstr(value),dstr(value2),bits256_str(str,txid),bits256_str(str2,txid2));
dispflag = 1;
if ( (selector= LP_mempool_vinscan(&spendtxid,&spendvini,symbol,txid,vout,txid2,vout2)) >= 0 )
{
printf("utxoadd selector.%d spent in mempool %s vini.%d",selector,bits256_str(str,spendtxid),spendvini);
return(0);
}
if ( (utxo= LP_utxofinds(iambob,txid,vout,txid2,vout2)) != 0 )
{
if ( 0 && LP_ismine(utxo) == 0 )
@ -632,6 +627,11 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,int32_t mypubsock,char *symbol,bit
if ( LP_ismine(utxo) > 0 )
utxo->T.sessionid = LP_sessionid;
else utxo->T.sessionid = sessionid;
if ( (selector= LP_mempool_vinscan(&spendtxid,&spendvini,symbol,txid,vout,txid2,vout2)) >= 0 )
{
printf("utxoadd selector.%d spent in mempool %s vini.%d",selector,bits256_str(str,spendtxid),spendvini);
utxo->T.spentflag = (uint32_t)time(NULL);
}
printf("U.%d %s %.8f %.8f addutxo.%d pubkey.%s session.%u\n",LP_mypeer!=0?LP_mypeer->numutxos:-1,symbol,dstr(value),dstr(value2),LP_ismine(utxo) > 0,bits256_str(str,utxo->pubkey),utxo->T.sessionid);
portable_mutex_lock(&LP_utxomutex);
HASH_ADD_KEYPTR(hh,LP_utxoinfos[iambob],utxo->key,sizeof(utxo->key),utxo);

Loading…
Cancel
Save