jl777 8 years ago
parent
commit
40351045ca
  1. 8
      iguana/iguana777.c
  2. 12
      iguana/iguana_ramchain.c
  3. 21
      iguana/iguana_spendvectors.c

8
iguana/iguana777.c

@ -447,7 +447,9 @@ void iguana_update_balances(struct supernet_info *myinfo,struct iguana_info *coi
max = coin->bundlescount;
if ( coin->bundles[max-1] == coin->current || coin->bundles[max-1] == 0 || (coin->bundles[max-1] != 0 && coin->bundles[max-1]->utxofinish <= 1) )
max--;
//coin->spendvectorsaved = 0;
coin->spendvectorsaved = 0;
iguana_utxogen(myinfo,coin,0,1);
if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) //
{
if ( coin->origbalanceswritten <= 1 )
@ -462,6 +464,7 @@ void iguana_update_balances(struct supernet_info *myinfo,struct iguana_info *coi
sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight);
OS_removefile(fname,0);
iguana_volatilesalloc(coin,&bp->ramchain,0);//i < hdrsi);
//iguana_Xspendmap(coin,&bp->ramchain,bp);
}
printf("accounts files purged\n");
sleep(3);
@ -515,8 +518,11 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int
if ( helperid < incr )
{
for (hdrsi=helperid; hdrsi<max; hdrsi+=incr)
{
coin->bundles[hdrsi]->utxofinish = 1;
num += iguana_helperA(myinfo,coin,helperid,coin->bundles[hdrsi],convertflag);
}
}
while ( (n= iguana_utxofinished(coin)) < max )
{
printf("helperid.%d %s utxofinished.%d vs %d\n",helperid,coin->symbol,n,max);

12
iguana/iguana_ramchain.c

@ -1322,6 +1322,8 @@ int32_t iguana_ramchain_extras(struct supernet_info *myinfo,struct iguana_info *
int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp)
{
int32_t iter; bits256 sha256; char str[65],fname[1024]; void *ptr; long filesize;
if ( ramchain->Xspendinds != 0 )
return(ramchain->numXspends);
for (iter=0; iter<2; iter++)
{
sprintf(fname,"%s/%s%s/spends/%s.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
@ -1342,10 +1344,10 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
printf("[%d] filesize %ld Xspendptr.%p %p num.%d\n",bp->hdrsi,filesize,ramchain->Xspendptr,ramchain->Xspendinds,ramchain->numXspends);
bp->Xvalid = 1;
}
printf("mapped utxo vector[%d] from (%s)\n",ramchain->numXspends,fname);
return(ramchain->numXspends);
//int32_t i; for (i=0; i<ramchain->numXspends; i++)
// printf("(%d u%d) ",ramchain->Xspendinds[i].hdrsi,ramchain->Xspendinds[i].ind);
//printf("mapped utxo vector[%d] from (%s)\n",ramchain->numXspends,fname);
}
else
{
@ -2014,7 +2016,7 @@ void iguana_blockdelete(struct iguana_info *coin,bits256 hash2,int32_t i)
void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile)
{
void *ptr; int32_t recvlen,height = -1; uint8_t zcash = 0;
if ( bp != 0 )
if ( 0 && bp != 0 )
printf("UNMARK.[%d:%d]\n",bp->hdrsi,i);
if ( block != 0 )
{
@ -2291,7 +2293,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig
if ( (mapchain= iguana_ramchain_map(myinfo,coin,fname,bp,bp->n,ramchain,0,0,bp->hashes[0],zero,0,0,extraflag,1,zcash)) != 0 )
{
iguana_ramchain_link(mapchain,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,1);
//char str[65]; printf("%s bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",coin->symbol,bp->hdrsi,mapchain->H.data->numtxids,mapchain->H.data->numunspents,mapchain->H.data->numspends,mapchain->H.data->numpkinds,mapchain->H.data->numexternaltxids,mbstr(str,mapchain->H.data->allocsize),mapchain->H.data);
char str[65]; printf("%s bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",coin->symbol,bp->hdrsi,mapchain->H.data->numtxids,mapchain->H.data->numunspents,mapchain->H.data->numspends,mapchain->H.data->numpkinds,mapchain->H.data->numexternaltxids,mbstr(str,mapchain->H.data->allocsize),mapchain->H.data);
//ramcoder_test(mapchain->H.data,mapchain->H.data->allocsize);
firsttxidind = 1;
if ( (rdata= ramchain->H.data) != 0 )
@ -2583,7 +2585,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi
//coin->blocks.RO[bp->bundleheight+bundlei] = block->RO;
iguana_blockzcopyRO(zcash,destB,bundlei,&block->RO,0);
//destB[bundlei] = block->RO;
//fprintf(stderr,"(%d %d).%d ",R[bundlei].H.data->numtxids,dest->H.txidind,bundlei);
//fprintf(stderr,"T.(%d %d u%d).%d ",R[bundlei].H.data->numtxids,dest->H.txidind,R[bundlei].H.data->numunspents,bundlei);
if ( (err= iguana_ramchain_iterate(myinfo,coin,dest,&R[bundlei],bp,bundlei)) != 0 )
{
if ( (block= bp->blocks[bundlei]) != 0 )
@ -2613,7 +2615,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi
memset(&newchain,0,sizeof(newchain));
if ( bundlei == endi+1 && iguana_ramchain_expandedsave(myinfo,coin,RAMCHAIN_DESTARG,&newchain,&HASHMEM,0,bp) == 0 )
{
//char str[65]; printf("d.%d ht.%d %s saved lag.%d elapsed.%ld\n",depth,dest->height,mbstr(str,dest->H.data->allocsize),now-starttime,time(NULL)-now);
char str[65]; printf("d.%d ht.%d %s saved\n",depth,dest->height,mbstr(str,dest->H.data->allocsize));
retval = 0;
} else bp->generrs++;
iguana_bundlemapfree(coin,mem,&HASHMEM,ipbits,ptrs,filesizes,num,R,starti,endi);

21
iguana/iguana_spendvectors.c

@ -56,7 +56,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp
int32_t i,retval = -1; FILE *fp; char fname[1024],str[65]; long fsize; bits256 zero,sha256;
if ( ptr == 0 || (bp->hdrsi != 0 && ptr == bp->ramchain.Xspendinds) )
{
//printf("iguana_spendvectorsave.[%d] ptr.%p Xspendinds\n",bp->hdrsi,ptr);
printf("iguana_spendvectorsave.[%d] ptr.%p Xspendinds\n",bp->hdrsi,ptr);
return(0);
}
memset(zero.bytes,0,sizeof(zero));
@ -84,7 +84,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp
printf("error mapping Xspendmap.(%s)\n",fname);
else
{
//printf("created.(%s) %p[%d]\n",fname,bp->ramchain.Xspendinds,bp->ramchain.numXspends);
printf("created.(%s) %p[%d]\n",fname,bp->ramchain.Xspendinds,bp->ramchain.numXspends);
retval = 0;
}
}
@ -263,7 +263,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi
bp->numtmpspends = ramchain->numXspends;
bp->utxofinish = (uint32_t)time(NULL);
bp->balancefinish = 0;
//printf("iguana_spendvectors.[%d]: already have Xspendinds[%d]\n",bp->hdrsi,ramchain->numXspends);
printf("iguana_spendvectors.[%d]: already have Xspendinds[%d]\n",bp->hdrsi,ramchain->numXspends);
return(0);
}
bp->startutxo = (uint32_t)time(NULL);
@ -474,7 +474,10 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
numXspends = bp->numtmpspends;
if ( (Xspendinds= bp->tmpspends) == 0 )
{
//printf("iguana_balancegen.%d: no Xspendinds[%d]\n",bp->hdrsi,numXspends);
printf("iguana_balancegen.%d: no Xspendinds[%d]\n",bp->hdrsi,numXspends);
numXspends = iguana_Xspendmap(coin,ramchain,bp);
numXspends = ramchain->numXspends;
printf("Xspendinds.%p[%d]\n",Xspendinds,numXspends);
//return(-1);
}
}
@ -483,7 +486,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
spendind = B[starti].firstvin;
unspentind = B[starti].firstvout;
emit = startemit;
if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) )
//if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) )
fprintf(stderr,"BALANCEGEN.[%d] %p[%d] starti.%d s%d <-> endi.%d s%d startemit.%d\n",bp->hdrsi,Xspendinds,numXspends,starti,spendind,endi,B[endi].firstvin+B[endi].numvins,startemit);
for (i=starti; i<=endi; i++)
{
@ -572,7 +575,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
else //if ( Xspendinds != 0 )
{
errs++;
printf("iguana_balancegen: spendind.%u external.%d error spentbp.%p with unspentind.%d pkind.%u [%d] (%d %d %d)\n",spendind,s->external,spentbp,spent_unspentind,spent_pkind,spent_hdrsi,i,j,k);
printf("iguana_balancegen: X%p[%d] spendind.%u external.%d error spentbp.%p with unspentind.%d pkind.%u [%d] (%d %d %d)\n",Xspendinds,numXspends,spendind,s->external,spentbp,spent_unspentind,spent_pkind,spent_hdrsi,i,j,k);
}
}
}
@ -1005,7 +1008,7 @@ int32_t iguana_spendvectorsaves(struct iguana_info *coin)
return(0);
coin->spendvectorsaved = 1;
n = coin->bundlescount - 1;
//printf("SAVE SPEND VECTORS %d of %d\n",n,coin->bundlescount);
printf("SAVE SPEND VECTORS %d of %d\n",n,coin->bundlescount);
for (iter=0; iter<2; iter++)
{
for (i=0; i<n; i++)
@ -1134,6 +1137,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c
if ( counter++ < 3 )
printf("need to process joinsplits before can validate.%s\n",coin->symbol);
bp->validated = (uint32_t)time(NULL);
forceflag = 1;
//return(bp->n);
}
if ( (coin->MAXPEERS > 1 && coin->VALIDATENODE == 0 && coin->FULLNODE == 0) || bp->ramchain.from_ro != 0 )//|| bp == coin->current )
@ -1160,6 +1164,8 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c
fclose(fp);
}
if ( forceflag != 0 || bp->validated <= 1 )
{
if ( coin->chain->zcash == 0 )
{
max = coin->blockspacesize;
blockspace = calloc(1,max);
@ -1186,6 +1192,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c
}
free(blockspace);
printf("%s %s VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d %llx\n",coin->symbol,errs!=0?"NOT":"",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated,(long long)validatehash.txid);
}
if ( errs == 0 )
bp->validated = (uint32_t)time(NULL);
else bp->validated = bp->startutxo = bp->utxofinish = 0;

Loading…
Cancel
Save