Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c58dc19715
  1. 37
      iguana/iguana777.c
  2. 8
      iguana/iguana_unspents.c

37
iguana/iguana777.c

@ -369,28 +369,29 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert
if ( incr < 1 ) if ( incr < 1 )
incr = 1; incr = 1;
} }
if ( helperid >= incr ) if ( helperid < incr )
return(0);
max = coin->bundlescount;
if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 )
max--;
for (hdrsi=helperid; hdrsi<max; hdrsi+=incr)
{ {
if ( (bp= coin->bundles[hdrsi]) == 0 ) max = coin->bundlescount;
return(-1); if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 )
//printf("validate incr.%d and gen utxo.[%d] utxofinish.%u Xspends.%p\n",incr,hdrsi,bp->utxofinish,bp->ramchain.Xspendinds); max--;
if ( strcmp("BTC",coin->symbol) == 0 || iguana_bundlevalidate(coin,bp,0) == bp->n ) for (hdrsi=helperid; hdrsi<max; hdrsi+=incr)
{ {
retval = 0; if ( (bp= coin->bundles[hdrsi]) == 0 )
if ( bp->utxofinish > 1 || (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,convertflag)) >= 0 ) return(-1);
//printf("validate incr.%d and gen utxo.[%d] utxofinish.%u Xspends.%p\n",incr,hdrsi,bp->utxofinish,bp->ramchain.Xspendinds);
if ( strcmp("BTC",coin->symbol) == 0 || iguana_bundlevalidate(coin,bp,0) == bp->n )
{ {
if ( retval > 0 ) retval = 0;
if ( bp->utxofinish > 1 || (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,convertflag)) >= 0 )
{ {
printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - bp->startutxo); if ( retval > 0 )
num++; {
} printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - bp->startutxo);
bp->utxofinish = (uint32_t)time(NULL); num++;
} else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi); }
bp->utxofinish = (uint32_t)time(NULL);
} else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi);
}
} }
} }
while ( (n= iguana_utxofinished(coin)) < max ) while ( (n= iguana_utxofinished(coin)) < max )

8
iguana/iguana_unspents.c

@ -141,7 +141,7 @@ int32_t iguana_alloccacheT(struct iguana_info *coin,struct iguana_ramchain *ramc
ramchain->cacheT = calloc(1,tlen); ramchain->cacheT = calloc(1,tlen);
memcpy(ramchain->cacheT,T,tlen); memcpy(ramchain->cacheT,T,tlen);
total += tlen; total += tlen;
char str[65]; printf("alloc.[%d] cacheT.%p[%d] total %s\n",ramchain->H.data->height/coin->chain->bundlesize,ramchain->cacheT,tlen,mbstr(str,total)); //char str[65]; printf("alloc.[%d] cacheT.%p[%d] total %s\n",ramchain->H.data->height/coin->chain->bundlesize,ramchain->cacheT,tlen,mbstr(str,total));
return(tlen); return(tlen);
} }
return(-1); return(-1);
@ -2010,10 +2010,11 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,
static int32_t totalerrs,totalvalidated; static int32_t totalerrs,totalvalidated;
FILE *fp; char fname[1024]; uint8_t *blockspace; uint32_t now = (uint32_t)time(NULL); FILE *fp; char fname[1024]; uint8_t *blockspace; uint32_t now = (uint32_t)time(NULL);
int32_t i,max,len,errs = 0; int64_t total = 0; int32_t i,max,len,errs = 0; int64_t total = 0;
//printf("validate.[%d]\n",bp->hdrsi); printf("validate.[%d]\n",bp->hdrsi);
if ( bp->validated <= 1 || forceflag != 0 ) if ( bp->validated <= 1 || forceflag != 0 )
{ {
sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight);
printf("validatefname.(%s)\n",fname);
if ( (fp= fopen(fname,"rb")) != 0 ) if ( (fp= fopen(fname,"rb")) != 0 )
{ {
if ( forceflag == 0 ) if ( forceflag == 0 )
@ -2022,7 +2023,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,
{ {
printf("error reading.(%s)\n",fname); printf("error reading.(%s)\n",fname);
total = bp->validated = 0; total = bp->validated = 0;
} //else printf("(%s) total.%d validated.%u\n",fname,(int32_t)total,bp->validated); } else printf("(%s) total.%d validated.%u\n",fname,(int32_t)total,bp->validated);
} else OS_removefile(fname,1); } else OS_removefile(fname,1);
fclose(fp); fclose(fp);
} }
@ -2032,6 +2033,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,
blockspace = calloc(1,max); blockspace = calloc(1,max);
for (i=0; i<bp->n; i++) for (i=0; i<bp->n; i++)
{ {
printf("i.%d: request\n",i);
if ( (len= iguana_peerblockrequest(coin,blockspace,max,0,bp->hashes[i],1)) < 0 ) if ( (len= iguana_peerblockrequest(coin,blockspace,max,0,bp->hashes[i],1)) < 0 )
{ {
errs++; errs++;

Loading…
Cancel
Save