Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
883a0b07f4
  1. 5
      iguana/iguana_spendvectors.c
  2. 58
      iguana/iguana_unspents.c
  3. 4
      iguana/iguana_volatiles.c
  4. 4
      includes/iguana_funcs.h
  5. 2
      includes/iguana_structs.h

5
iguana/iguana_spendvectors.c

@ -505,7 +505,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
for (k=0; k<T[txidind].numvouts && errs==0; k++,unspentind++) for (k=0; k<T[txidind].numvouts && errs==0; k++,unspentind++)
{ {
u = &U[unspentind]; u = &U[unspentind];
if ( (utxoaddr= iguana_utxoaddrfind(1,coin,P[u->pkind].rmd160,&coin->RTprev)) != 0 ) if ( (utxoaddr= iguana_utxoaddrfind(1,coin,bp->hdrsi,u->pkind,P[u->pkind].rmd160,&coin->RTprev)) != 0 )
{ {
utxoaddr->RTcredits += u->value; utxoaddr->RTcredits += u->value;
coin->RTcredits += u->value; coin->RTcredits += u->value;
@ -912,8 +912,7 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi)
} }
} }
char str[65]; printf("BALANCES WRITTEN for %d orig.%d bundles %s\n",coin->balanceswritten,coin->origbalanceswritten,bits256_str(str,coin->balancehash)); char str[65]; printf("BALANCES WRITTEN for %d orig.%d bundles %s\n",coin->balanceswritten,coin->origbalanceswritten,bits256_str(str,coin->balancehash));
//if ( coin->utxoaddrs == 0 ) iguana_utxoaddr_gen(coin,(coin->balanceswritten-1) * coin->chain->bundlesize);
iguana_utxoaddr_gen(coin,1);
if ( 0 && coin->balanceswritten > coin->origbalanceswritten+10 ) // strcmp(coin->symbol,"BTC") == 0 && if ( 0 && coin->balanceswritten > coin->origbalanceswritten+10 ) // strcmp(coin->symbol,"BTC") == 0 &&
{ {
coin->active = 0; coin->active = 0;

58
iguana/iguana_unspents.c

@ -843,7 +843,7 @@ int64_t iguana_unspentavail(struct supernet_info *myinfo,struct iguana_info *coi
else return(0); else return(0);
} }
struct iguana_utxoaddr *iguana_utxoaddrfind(int32_t createflag,struct iguana_info *coin,uint8_t rmd160[20],struct iguana_utxoaddr **prevp) struct iguana_utxoaddr *iguana_utxoaddrfind(int32_t createflag,struct iguana_info *coin,int16_t hdrsi,uint32_t pkind,uint8_t rmd160[20],struct iguana_utxoaddr **prevp)
{ {
struct iguana_utxoaddr *utxoaddr; struct iguana_utxoaddr *utxoaddr;
HASH_FIND(hh,coin->utxoaddrs,rmd160,sizeof(utxoaddr->rmd160),utxoaddr); HASH_FIND(hh,coin->utxoaddrs,rmd160,sizeof(utxoaddr->rmd160),utxoaddr);
@ -851,6 +851,8 @@ struct iguana_utxoaddr *iguana_utxoaddrfind(int32_t createflag,struct iguana_inf
{ {
utxoaddr = calloc(1,sizeof(*utxoaddr)); utxoaddr = calloc(1,sizeof(*utxoaddr));
++coin->utxoaddrind; ++coin->utxoaddrind;
utxoaddr->hdrsi = hdrsi;
utxoaddr->pkind = pkind;
memcpy(utxoaddr->rmd160,rmd160,sizeof(utxoaddr->rmd160)); memcpy(utxoaddr->rmd160,rmd160,sizeof(utxoaddr->rmd160));
HASH_ADD_KEYPTR(hh,coin->utxoaddrs,utxoaddr->rmd160,sizeof(utxoaddr->rmd160),utxoaddr); HASH_ADD_KEYPTR(hh,coin->utxoaddrs,utxoaddr->rmd160,sizeof(utxoaddr->rmd160),utxoaddr);
if ( prevp != 0 ) if ( prevp != 0 )
@ -897,7 +899,7 @@ int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp
{ {
if ( (pkind= U[unspentind].pkind) < rdata->numpkinds && pkind > 0 ) if ( (pkind= U[unspentind].pkind) < rdata->numpkinds && pkind > 0 )
{ {
if ( (utxoaddr= iguana_utxoaddrfind(1,coin,P[pkind].rmd160,prevp)) != 0 ) if ( (utxoaddr= iguana_utxoaddrfind(1,coin,bp->hdrsi,pkind,P[pkind].rmd160,prevp)) != 0 )
{ {
//printf("%.8f ",dstr(value)); //printf("%.8f ",dstr(value));
utxoaddr->balance += value; utxoaddr->balance += value;
@ -911,54 +913,48 @@ int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp
return(balance); return(balance);
} }
int64_t iguana_utxoaddr_gen(struct iguana_info *coin,int32_t maketable) int64_t iguana_utxoaddr_gen(struct iguana_info *coin,int32_t maxheight)
{ {
struct iguana_utxoaddr *utxoaddr,*tmp,*last=0; int32_t hdrsi,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0; struct iguana_utxoaddr *utxoaddr,*tmp,*last=0; int32_t hdrsi,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0;
if ( maketable != 0 ) printf("utxoaddr_gen.%d\n",maxheight);
if ( coin->utxoaddrs != 0 )
{ {
if ( coin->utxoaddrs != 0 ) printf("free %s utxoaddrs\n",coin->symbol);
HASH_ITER(hh,coin->utxoaddrs,utxoaddr,tmp)
{ {
printf("free %s utxoaddrs\n",coin->symbol); if ( utxoaddr != 0 )
HASH_ITER(hh,coin->utxoaddrs,utxoaddr,tmp)
{ {
if ( utxoaddr != 0 ) HASH_DELETE(hh,coin->utxoaddrs,utxoaddr);
{ free(utxoaddr);
HASH_DELETE(hh,coin->utxoaddrs,utxoaddr);
free(utxoaddr);
}
} }
coin->utxoaddrs = 0;
} }
for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++) coin->utxoaddrs = 0;
if ( (bp= coin->bundles[hdrsi]) != 0 && (rdata= bp->ramchain.H.data) != 0 )
{
tablesize += rdata->numpkinds;
}
printf("allocate UTXOADDRS[%d]\n",tablesize);
coin->utxodatasize = tablesize;
coin->utxoaddrind = 0;
} }
for (hdrsi=0; hdrsi<coin->bundlescount; hdrsi++)
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight && (rdata= bp->ramchain.H.data) != 0 )
{
tablesize += rdata->numpkinds;
}
printf("allocate UTXOADDRS[%d]\n",tablesize);
coin->utxodatasize = tablesize;
coin->utxoaddrind = 0;
for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++) for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++)
{ {
balance += iguana_bundle_unspents(coin,coin->bundles[hdrsi],maketable,&last); balance += iguana_bundle_unspents(coin,coin->bundles[hdrsi],1,&last);
fprintf(stderr,"(%d %.8f) ",hdrsi,dstr(balance)); fprintf(stderr,"(%d %.8f) ",hdrsi,dstr(balance));
} }
fprintf(stderr,"%d bundles for iguana_utxoaddr_gen.[%d] max.%d %p\n",hdrsi,coin->utxoaddrind,coin->utxodatasize,coin->utxoaddrs); fprintf(stderr,"%d bundles for iguana_utxoaddr_gen.[%d] max.%d ht.%d\n",hdrsi,coin->utxoaddrind,coin->utxodatasize,maxheight);
for (utxoaddr=last; utxoaddr!=0; utxoaddr=utxoaddr->hh.prev) for (utxoaddr=last; utxoaddr!=0; utxoaddr=utxoaddr->hh.prev)
{ {
if ( utxoaddr != 0 )
{
if ( utxoaddr->balance > 0 ) if ( utxoaddr->balance > 0 )
{
//int32_t i; for (i=0; i<20; i++)
// printf("%02x",utxoaddr->rmd160[i]);
//printf(" %.8f\n",dstr(utxoaddr->balance));
checkbalance += utxoaddr->balance; checkbalance += utxoaddr->balance;
}
else printf("error neg or zero balance %.8f\n",dstr(utxoaddr->balance)); else printf("error neg or zero balance %.8f\n",dstr(utxoaddr->balance));
} else printf("null utxoaddr?\n");
} }
printf("checkbalance %.8f vs %.8f\n",dstr(checkbalance),dstr(balance)); printf("checkbalance %.8f vs %.8f\n",dstr(checkbalance),dstr(balance));
if ( checkbalance == balance )
{
}
coin->histbalance = balance; coin->histbalance = balance;
return(balance); return(balance);
} }

4
iguana/iguana_volatiles.c

@ -79,7 +79,7 @@ int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t
hhacct->a.lastunspentind = spent_unspentind; hhacct->a.lastunspentind = spent_unspentind;
hhacct->a.total += spent_value; hhacct->a.total += spent_value;
struct iguana_utxoaddr *utxoaddr; struct iguana_utxoaddr *utxoaddr;
if ( (utxoaddr= iguana_utxoaddrfind(1,coin,rmd160,&coin->RTprev)) != 0 ) if ( (utxoaddr= iguana_utxoaddrfind(1,coin,spent_hdrsi,spent_pkind,rmd160,&coin->RTprev)) != 0 )
{ {
utxoaddr->RTdebits += spent_value; utxoaddr->RTdebits += spent_value;
coin->RTdebits += spent_value; coin->RTdebits += spent_value;
@ -217,7 +217,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
//double startmillis = OS_milliseconds(); static double totalmillis; static int32_t utxon; //double startmillis = OS_milliseconds(); static double totalmillis; static int32_t utxon;
spentP = RAMCHAIN_PTR(rdata,Poffset); spentP = RAMCHAIN_PTR(rdata,Poffset);
spentU = RAMCHAIN_PTR(rdata,Uoffset); spentU = RAMCHAIN_PTR(rdata,Uoffset);
if ( iguana_utxoupdate(coin,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,fromheight,spentP[spentU[spent_unspentind].pkind].rmd160) == 0 ) if ( iguana_utxoupdate(coin,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,fromheight,spentP[spent_pkind].rmd160) == 0 )
{ {
/*totalmillis += (OS_milliseconds() - startmillis); /*totalmillis += (OS_milliseconds() - startmillis);
if ( (++utxon % 100000) == 0 ) if ( (++utxon % 100000) == 0 )

4
includes/iguana_funcs.h

@ -327,7 +327,7 @@ void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct ig
int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp); int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp);
int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate); int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate);
int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct iguana_bundle *bp,int32_t startheight,int32_t endheight,int32_t startemit); int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct iguana_bundle *bp,int32_t startheight,int32_t endheight,int32_t startemit);
struct iguana_utxoaddr *iguana_utxoaddrfind(int32_t createflag,struct iguana_info *coin,uint8_t rmd160[20],struct iguana_utxoaddr **prevp); struct iguana_utxoaddr *iguana_utxoaddrfind(int32_t createflag,struct iguana_info *coin,int16_t hdrsi,uint32_t pkind,uint8_t rmd160[20],struct iguana_utxoaddr **prevp);
int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,int32_t forceflag); int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,int32_t forceflag);
void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp);
struct iguana_bloominds iguana_calcbloom(bits256 hash2); struct iguana_bloominds iguana_calcbloom(bits256 hash2);
@ -520,7 +520,7 @@ int32_t iguana_headerget(struct iguana_info *coin,uint8_t *serialized,int32_t ma
int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct OS_memspace *mem,struct OS_memspace *memB); int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct OS_memspace *mem,struct OS_memspace *memB);
bits256 iguana_parsetxobj(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *txstartp,uint8_t *serialized,int32_t maxsize,struct iguana_msgtx *msg,cJSON *txobj,struct vin_info *V); bits256 iguana_parsetxobj(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *txstartp,uint8_t *serialized,int32_t maxsize,struct iguana_msgtx *msg,cJSON *txobj,struct vin_info *V);
int32_t iguana_ROallocsize(struct iguana_info *virt); int32_t iguana_ROallocsize(struct iguana_info *virt);
int64_t iguana_utxoaddr_gen(struct iguana_info *coin,int32_t maketable); int64_t iguana_utxoaddr_gen(struct iguana_info *coin,int32_t maxheight);
long iguana_bundlesload(struct supernet_info *myinfo,struct iguana_info *coin); long iguana_bundlesload(struct supernet_info *myinfo,struct iguana_info *coin);
void basilisk_wait(struct supernet_info *myinfo,struct iguana_info *coin); void basilisk_wait(struct supernet_info *myinfo,struct iguana_info *coin);
int32_t bitcoin_pubkey_combine(void *ctx,uint8_t *combined_pub,uint8_t *skipkey,bits256 *evenkeys,int32_t n,bits256 *oddkeys,int32_t m); int32_t bitcoin_pubkey_combine(void *ctx,uint8_t *combined_pub,uint8_t *skipkey,bits256 *evenkeys,int32_t n,bits256 *oddkeys,int32_t m);

2
includes/iguana_structs.h

@ -253,7 +253,7 @@ struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spent
struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; } __attribute__((packed)); struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; } __attribute__((packed));
struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; } __attribute__((packed)); struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; } __attribute__((packed));
struct iguana_utxoaddr { UT_hash_handle hh; int64_t balance,RTcredits,RTdebits; uint8_t rmd160[20]; } __attribute__((packed)); struct iguana_utxoaddr { UT_hash_handle hh; int64_t balance,RTcredits,RTdebits; uint32_t pkind; uint16_t hdrsi; uint8_t rmd160[20]; } __attribute__((packed));
// GLOBAL one zero to non-zero write (unless reorg) // GLOBAL one zero to non-zero write (unless reorg)
struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; } __attribute__((packed)); // unspentind struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; } __attribute__((packed)); // unspentind

Loading…
Cancel
Save