Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
725c519b9e
  1. 23
      deprecated/obsolete.h
  2. 2
      iguana/iguana777.h
  3. 16
      iguana/iguana_unspents.c
  4. 23
      iguana/main.c

23
deprecated/obsolete.h

@ -16172,6 +16172,29 @@ len = 0;
jaddnum(retitem,"result",coin->blocks.hwmchain.height);
return(jprint(retitem,1));
}*/
if ( 0 )
{
int32_t i,n; int64_t total; char *coinaddr; struct iguana_pkhash *P; struct iguana_info *coin; uint8_t rmd160[20],addrtype,pubkey33[33]; double startmillis;
coin = iguana_coinfind("BTCD");
if ( 1 && coin != 0 )
{
getchar();
for (i=0; i<coin->bundlescount; i++)
if ( coin->bundles[i] == 0 )
break;
coinaddr = "RUZ9AKxy6J2okcBd1PZm4YH6atmPwqV4bo";
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
P = calloc(coin->bundlescount,sizeof(*P));
memset(pubkey33,0,sizeof(pubkey33));
n = iguana_pkhasharray(coin,0,0,0,&total,P,coin->bundlescount,rmd160,coinaddr,pubkey33);
printf("%s has total outputs %.8f from %d bundles\n",coinaddr,dstr(total),n);
startmillis = OS_milliseconds();
for (i=0; i<1000; i++)
n = iguana_pkhasharray(coin,0,0,0,&total,P,coin->bundlescount,rmd160,coinaddr,pubkey33);
printf("%s has total outputs %.8f from %d bundles %.3f millis\n",coinaddr,dstr(total),n,OS_milliseconds()-startmillis);
getchar();
}
}
#endif
#endif

2
iguana/iguana777.h

@ -804,7 +804,7 @@ char *issue_startForging(struct supernet_info *myinfo,char *secret);
struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct iguana_info *coin,char **retstrp,double *balancep,int32_t *numunspentsp,double minconfirms,char *account);
void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson);
void iguana_addinputs(struct iguana_info *coin,struct bitcoin_spend *spend,cJSON *txobj,uint32_t sequence);
int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33);
int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight);
long iguana_spentsfile(struct iguana_info *coin,int32_t n);
uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti);
void iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds);

16
iguana/iguana_unspents.c

@ -889,7 +889,7 @@ int64_t iguana_pkhashbalance(struct iguana_info *coin,cJSON *array,int64_t *spen
return(deposits - spent);
}
int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33)
int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight)
{
int32_t i,n,m; int64_t spent,deposits,netbalance,total; uint32_t lastunspentind; struct iguana_ramchain *ramchain;
if ( 0 && coin->RTramchain_busy != 0 )
@ -897,11 +897,13 @@ int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf
printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n");
return(-1);
}
if ( lastheight/coin->chain->bundlesize < max )
max = lastheight/coin->chain->bundlesize;
for (total=i=n=0; i<max && i<coin->bundlescount; i++)
{
if ( iguana_pkhashfind(coin,&ramchain,&deposits,&lastunspentind,&P[n],rmd160,i,i) != 0 )
{
if ( (netbalance= iguana_pkhashbalance(coin,array,&spent,&m,ramchain,&P[n],lastunspentind,rmd160,coinaddr,pubkey33,i,0)) != deposits-spent )
if ( (netbalance= iguana_pkhashbalance(coin,array,&spent,&m,ramchain,&P[n],lastunspentind,rmd160,coinaddr,pubkey33,i,lastheight)) != deposits-spent )
{
printf("pkhash balance mismatch from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent));
}
@ -934,7 +936,7 @@ void iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON
for (i=0; i<numrmds; i++)
{
bitcoin_address(coinaddr,addrtypes[i],&rmdarray[i * 20],20);
iguana_pkhasharray(coin,array,minconf,maxconf,&total,P,coin->bundlescount,&rmdarray[i * 20],coinaddr,&pubkeys[33*i]);
iguana_pkhasharray(coin,array,minconf,maxconf,&total,P,coin->bundlescount,&rmdarray[i * 20],coinaddr,&pubkeys[33*i],0);
printf("i.%d of %d: %s %.8f\n",i,numrmds,coinaddr,dstr(total));
sum += total;
}
@ -2141,6 +2143,8 @@ TWOSTRINGS_AND_INT(iguana,balance,activecoin,address,height)
{
int32_t minconf=1,maxconf=SATOSHIDEN; int64_t total; uint8_t rmd160[20],pubkey33[33],addrtype;
struct iguana_pkhash *P; cJSON *array,*retjson = cJSON_CreateObject();
if ( activecoin != 0 && activecoin[0] != 0 )
coin = iguana_coinfind(activecoin);
if ( coin != 0 )
{
jaddstr(retjson,"address",address);
@ -2154,15 +2158,15 @@ TWOSTRINGS_AND_INT(iguana,balance,activecoin,address,height)
jaddstr(retjson,"error","cant convert address");
return(jprint(retjson,1));
}
if ( height != 0 )
jaddnum(retjson,"height",height);
memset(pubkey33,0,sizeof(pubkey33));
P = calloc(coin->bundlescount,sizeof(*P));
array = cJSON_CreateArray();
iguana_pkhasharray(coin,array,minconf,maxconf,&total,P,coin->bundlescount,rmd160,address,pubkey33);
iguana_pkhasharray(coin,array,minconf,maxconf,&total,P,coin->bundlescount,rmd160,address,pubkey33,height);
free(P);
jadd(retjson,"unspents",array);
jaddnum(retjson,"balance",dstr(total));
if ( height != 0 )
jaddnum(retjson,"height",height);
}
return(jprint(retjson,1));
}

23
iguana/main.c

@ -1158,29 +1158,6 @@ void iguana_appletests(struct supernet_info *myinfo)
}
sleep(1);
}
if ( 0 )
{
int32_t i,n; int64_t total; char *coinaddr; struct iguana_pkhash *P; struct iguana_info *coin; uint8_t rmd160[20],addrtype,pubkey33[33]; double startmillis;
coin = iguana_coinfind("BTCD");
if ( 1 && coin != 0 )
{
getchar();
for (i=0; i<coin->bundlescount; i++)
if ( coin->bundles[i] == 0 )
break;
coinaddr = "RUZ9AKxy6J2okcBd1PZm4YH6atmPwqV4bo";
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
P = calloc(coin->bundlescount,sizeof(*P));
memset(pubkey33,0,sizeof(pubkey33));
n = iguana_pkhasharray(coin,0,0,0,&total,P,coin->bundlescount,rmd160,coinaddr,pubkey33);
printf("%s has total outputs %.8f from %d bundles\n",coinaddr,dstr(total),n);
startmillis = OS_milliseconds();
for (i=0; i<1000; i++)
n = iguana_pkhasharray(coin,0,0,0,&total,P,coin->bundlescount,rmd160,coinaddr,pubkey33);
printf("%s has total outputs %.8f from %d bundles %.3f millis\n",coinaddr,dstr(total),n,OS_milliseconds()-startmillis);
getchar();
}
}
}
void iguana_commandline(struct supernet_info *myinfo,char *arg)

Loading…
Cancel
Save