Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
a62b335272
  1. 6
      iguana/iguana777.c
  2. 2
      iguana/iguana777.h
  3. 2
      iguana/iguana_blocks.c
  4. 10
      iguana/iguana_bundles.c
  5. 6
      iguana/iguana_init.c
  6. 24
      iguana/iguana_ramchain.c
  7. 36
      iguana/iguana_unspents.c
  8. 6
      iguana/main.c

6
iguana/iguana777.c

@ -361,9 +361,9 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert
{
int32_t hdrsi,retval,n,max,incr,num = 0; struct iguana_bundle *bp;
incr = IGUANA_NUMHELPERS;
if ( coin->PREFETCHLAG > 0 )
if ( 1 && coin->PREFETCHLAG > 0 )
{
incr /= 2;
incr = 1;
if ( incr < 1 )
incr = 1;
}
@ -382,7 +382,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert
{
if ( (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,convertflag)) >= 0 )
{
printf("spendvectors retval.%d\n",retval);
//printf("spendvectors retval.%d\n",retval);
if ( retval > 0 )
{
printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - bp->startutxo);

2
iguana/iguana777.h

@ -477,7 +477,7 @@ struct iguana_info
struct iguana_peers peers; struct iguana_peer internaladdr;
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles;
int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,origbalanceswritten,balanceswritten,RTheight;
int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,origbalanceswritten,balanceswritten,RTheight,RTdatabad;
bits256 balancehash,allbundles;
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats; char VALIDATEDIR[512];
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy,stuckiters;

2
iguana/iguana_blocks.c

@ -527,6 +527,8 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
{
char str[65],str2[65];
printf("ERROR: need to fix up bundle for height.%d (%p %p) (%s %s)\n",block->height,block,bp->blocks[block->height % coin->chain->bundlesize],bits256_str(str,block->RO.hash2),bits256_str(str2,bp->hashes[block->height % coin->chain->bundlesize]));
if ( bp == coin->current && coin->RTheight > 0 )
coin->RTdatabad = 1;
//iguana_bundleremove(coin,bp->hdrsi,0);
//exit(-1);
//getchar();

10
iguana/iguana_bundles.c

@ -751,11 +751,17 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int
}
else
#endif
{
iguana_blockunmark(coin,block,bp,i,1);
if ( requiredflag != 0 )
printf("not ready altpath.(%d %d %d %d %d) [%d:%d]\n",block->txvalid == 0,block->fpipbits == 0 ,block->fpos < 0,(bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0),iguana_blockvalidate(coin,&valid,block,1) < 0,bp->hdrsi,i);
}
}
}
else
{
if ( requiredflag != 0 )
printf("no block at [%d:%d]\n",bp->hdrsi,i);
iguana_blockunmark(coin,block,bp,i,0);
if ( bp->queued != 0 )
{
@ -945,7 +951,7 @@ int32_t iguana_bundlefinalize(struct iguana_info *coin,struct iguana_bundle *bp,
}
else
{
fprintf(stderr,"emitQ done coin.%p bp.[%d] ht.%d error\n",coin,bp->hdrsi,bp->bundleheight);
//fprintf(stderr,"emitQ done coin.%p bp.[%d] ht.%d error\n",coin,bp->hdrsi,bp->bundleheight);
bp->emitfinish = 0;
}
coin->emitbusy--;
@ -994,7 +1000,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
{
if ( iguana_bundlefinalize(coin,bp,mem,memB) > 0 )
return(0);
else printf("bundlefinalize not done.[%d]\n",bp->hdrsi);
//else printf("bundlefinalize not done.[%d]\n",bp->hdrsi);
retval = 1;
}
else if ( bp->hdrsi == starti || (bp->hdrsi >= starti && bp->hdrsi <= starti+range) )

6
iguana/iguana_init.c

@ -207,11 +207,12 @@ int32_t iguana_bundleinitmap(struct iguana_info *coin,struct iguana_bundle *bp,i
coin->current = coin->bundles[0] = bp;
if ( (block= iguana_blockfind("parse",coin,hash2)) != 0 )
block->mainchain = 1, block->height = height;
bp->emitfinish = (uint32_t)time(NULL) + 1;
if ( iguana_bundleload(coin,&bp->ramchain,bp,2) != 0 )
{
if ( coin->current != 0 && coin->current->hdrsi+1 == bp->hdrsi )
coin->current = bp;
bp->emitfinish = (uint32_t)time(NULL) + 1;
//printf("[%d %u] ",bp->hdrsi,bp->emitfinish);
return(0);
}
else
@ -222,6 +223,7 @@ int32_t iguana_bundleinitmap(struct iguana_info *coin,struct iguana_bundle *bp,i
//printf("init reqhdrs.%d\n",bp->bundleheight);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str),1);
memset(&hash2,0,sizeof(hash2));
bp->emitfinish = 0;
return(-1);
}
}
@ -328,7 +330,7 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
printf("mismatched allhash.[%d]\n",bp->hdrsi);
bp->allhash = allhash;
}
if ( height > lastheight )
if ( height >= lastheight )
{
if ( iguana_bundleinitmap(coin,bp,height,hash2,hash1) == 0 )
lastbundle = hash2, lastheight = height;

24
iguana/iguana_ramchain.c

@ -629,7 +629,7 @@ void *_iguana_ramchain_setptrs(RAMCHAIN_PTRPS,struct iguana_ramchaindata *rdata)
void *iguana_ramchain_offset(char *fname,void *dest,uint8_t *lhash,FILE *fp,uint64_t fpos,void *srcptr,uint64_t *offsetp,uint64_t len,uint64_t srcsize)
{
long err;
long err,startfpos;
void *destptr = (void *)(long)((long)dest + *offsetp);
if ( (lhash != 0 || fp != 0) && (*offsetp + len) > srcsize )
{
@ -643,15 +643,18 @@ void *iguana_ramchain_offset(char *fname,void *dest,uint8_t *lhash,FILE *fp,uint
}
else if ( fp != 0 )
{
startfpos = ftell(fp);
if ( (err= fwrite(srcptr,1,len,fp)) != len )
{
printf("iguana_ramchain_offset.(%s): error.%ld writing len.%ld to fp.%p errno.%d\n",fname,err,(long)len,fp,errno);
printf("probably out of disk space. please free up space\n");
fprintf(stderr,"iguana_ramchain_sizefunc.(%s): error.%ld writing len.%ld to fp.%p errno.%d\n",fname,err,(long)len,fp,errno);
fprintf(stderr,"probably out of disk space. please free up space\n");
fseek(fp,0,SEEK_SET);
len = 0;
fpos = 0;
sleep(1);
fseek(fp,startfpos,SEEK_SET);
if ( (err= fwrite(srcptr,1,len,fp)) == len )
printf("second write worked!\n");
else fpos = len = 0;
}
//else printf("fp.(%ld <- %d) ",ftell(fp),(int32_t)len);
}
@ -1018,8 +1021,8 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits
}
}*/
#ifdef __PNACL__
static portable_mutex_t mutex;
portable_mutex_lock(&mutex);
//static portable_mutex_t mutex;
//portable_mutex_lock(&mutex);
#endif
if ( (fp= fopen(fname,"wb")) == 0 )
printf("iguana_ramchain_save: couldnt create.(%s) errno.%d\n",fname,errno);
@ -1042,7 +1045,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits
fclose(fp);
}
#ifdef __PNACL__
portable_mutex_unlock(&mutex);
//portable_mutex_unlock(&mutex);
#endif
return(fpos);
}
@ -1252,7 +1255,7 @@ int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfi
struct iguana_bundle *bp; int32_t i; char fname[1024],str[65];
if ( hdrsi >= 0 && hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 )
{
//printf("delete bundle.[%d]\n",hdrsi);
printf("delete bundle.[%d]\n",hdrsi);
if ( tmpfiles != 0 )
{
for (i=0; i<bp->n; i++)
@ -2002,7 +2005,7 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru
fname[0] = 0;
if ( block != 0 && (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,0,block->RO.hash2,zero,1,1)) != i )
{
printf("checki.%d vs %d mismatch? %s\n",checki,i,fname);
//printf("checki.%d vs %d mismatch? %s\n",checki,i,fname);
}
if ( fname[0] != 0 )
OS_removefile(fname,0);
@ -2263,7 +2266,8 @@ struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana
{
//printf("couldnt load bundle.%d\n",bp->bundleheight);
memset(&bp->ramchain,0,sizeof(bp->ramchain));
iguana_bundleremove(coin,bp->hdrsi,0);
bp->emitfinish = 0;
//iguana_bundleremove(coin,bp->hdrsi,0);
}
if ( mapchain != 0 )
coin->newramchain++;

36
iguana/iguana_unspents.c

@ -307,8 +307,13 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
}
}
printf("iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind);
iguana_bundleremove(coin,spent_hdrsi,0);
iguana_bundleremove(coin,fromheight/coin->chain->bundlesize,0);
if ( coin->current != 0 && coin->current->hdrsi == fromheight/coin->chain->bundlesize )
coin->RTdatabad = 1;
else
{
iguana_bundleremove(coin,spent_hdrsi,0);
iguana_bundleremove(coin,fromheight/coin->chain->bundlesize,0);
}
exit(-1);
}
return(-1);
@ -947,7 +952,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,st
ptr = mycalloc('x',sizeof(*ptr),n);
total += n;
startmillis = OS_milliseconds();
//if ( 0 && strcmp(coin->symbol,"BTC") == 0 )
if ( 0 && strcmp(coin->symbol,"BTC") == 0 )
printf("start UTXOGEN.%d max.%d ptr.%p millis.%.3f\n",bp->bundleheight,n,ptr,startmillis);
starttime = (uint32_t)time(NULL);
txidind = B[starti].firsttxidind;
@ -1241,7 +1246,7 @@ int32_t iguana_volatilesinit(struct iguana_info *coin)
printf("volatile init\n");
for (i=0; i<coin->balanceswritten; i++)
{
if ( (bp= coin->bundles[i]) == 0 || bp->emitfinish <= 1 || bp->utxofinish <= 1 )
if ( (bp= coin->bundles[i]) == 0 || bp->emitfinish <= 1 || (i > 0 && bp->utxofinish <= 1) )
{
printf("hdrsi.[%d] emitfinish.%u utxofinish.%u\n",i,bp->emitfinish,bp->utxofinish);
break;
@ -1341,21 +1346,21 @@ void iguana_initfinal(struct iguana_info *coin,bits256 lastbundle)
printf("req lastbundle.(%s)\n",hashstr);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1);
}
for (i=1; i<coin->bundlescount-1; i++)
for (i=0; i<coin->bundlescount-1; i++)
{
if ( (bp= coin->bundles[i]) == 0 || bp->utxofinish <= 1 )
if ( (bp= coin->bundles[i]) == 0 || bp->emitfinish <= 1 )
{
printf("initfinal break.[%d]: bp.%p or utxofinish.%u\n",i,bp,bp!=0?bp->utxofinish:-1);
printf("initfinal break.[%d]: bp.%p or emit.%u utxofinish.%u\n",i,bp,bp!=0?bp->emitfinish:-1,bp!=0?bp->utxofinish:-1);
break;
}
}
if ( i < coin->bundlescount-1 )
{
//printf("spendvectors.[%d] missing, will regen all of them\n",i);
//printf("spendvectors.[%d] max.%d missing, will regen all of them\n",i,coin->bundlescount-1);
for (i=0; i<coin->bundlescount-1; i++)
{
if ( coin->bundles[i] != 0 )
coin->bundles[i]->startutxo = coin->bundles[i]->utxofinish = 0;
if ( (bp= coin->bundles[i]) != 0 )
bp->startutxo = bp->utxofinish = 0;
}
}
printf("i.%d bundlescount.%d\n",i,coin->bundlescount);
@ -1671,6 +1676,7 @@ void iguana_RTramchainfree(struct iguana_info *coin)
iguana_ramchain_free(coin,&coin->RTramchain,1);
iguana_mempurge(&coin->RTmem);
iguana_mempurge(&coin->RThashmem);
coin->RTdatabad = 0;
}
void *iguana_ramchainfile(struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *R,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block)
@ -1742,7 +1748,7 @@ void iguana_rdataset(struct iguana_ramchain *dest,struct iguana_ramchaindata *rd
rdest->numtxids = src->H.txidind;
rdest->numunspents = src->H.unspentind;
rdest->numspends = src->H.spendind;
printf("RT set numtxids.%u numspends.%u\n",rdest->numtxids,rdest->numspends);
//printf("RT set numtxids.%u numspends.%u\n",rdest->numtxids,rdest->numspends);
}
void iguana_rdatarestore(struct iguana_ramchain *dest,struct iguana_ramchaindata *rdest,struct iguana_ramchain *src)
@ -1794,7 +1800,7 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
//printf("spendvectors converted to %d\n",coin->RTheight);
bp->converted = (uint32_t)time(NULL);
iguana_balancegen(coin,0,bp,coin->RTstarti,coin->RTheight-1,orignumemit);
printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n);
//printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n);
coin->RTstarti = (coin->RTheight % bp->n);
}
}
@ -1804,6 +1810,8 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
double startmillis0; static double totalmillis0; static int32_t num0;
struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t bundlei,i,n,flag=0; bits256 hash2; struct iguana_peer *addr;
struct iguana_block *block=0; struct iguana_blockRO *B; struct iguana_ramchain *dest=0,blockR;
if ( coin->RTdatabad != 0 )
iguana_RTramchainfree(coin);
if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && ((coin->RTheight <= coin->blocks.hwmchain.height && time(NULL) > bp->lastRT) || time(NULL) > bp->lastRT+10) )
{
if ( (block= bp->blocks[0]) == 0 || block->txvalid == 0 || block->mainchain == 0 )
@ -1896,7 +1904,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
printf("ramchainiterate.[%d] ave %.2f micros, total %.2f seconds starti.%d num.%d\n",num0,(totalmillis0*1000.)/num0,totalmillis0/1000.,coin->RTstarti,coin->RTheight%bp->n);
if ( (n= iguana_walkchain(coin,1)) == coin->RTheight-1 )
{
printf("RTgenesis verified\n");
//printf("RTgenesis verified\n");
coin->RTgenesis = (uint32_t)time(NULL);
iguana_RTspendvectors(coin,bp);
}
@ -1909,6 +1917,8 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
}
if ( dest != 0 && flag != 0 )
printf("<<<< flag.%d RT.%d:%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",flag,coin->RTheight,n,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,dest->H.data!=0?(long)dest->H.data->allocsize:-1);
if ( coin->RTdatabad != 0 )
iguana_RTramchainfree(coin);
return(flag);
}

6
iguana/main.c

@ -68,12 +68,12 @@ int32_t HDRnet,netBLOCKS;
cJSON *API_json;
#ifdef __PNACL__
char GLOBAL_TMPDIR[512] = "/tmp";
char GLOBAL_TMPDIR[512] = "/DB/tmp";
char GLOBAL_DBDIR[512] = "/DB";
char GLOBAL_HELPDIR[512] = "/DB/help";
char GLOBAL_VALIDATEDIR[512] = "/DB/purgeable";
char GLOBAL_CONFSDIR[512] = "/DB/confs";
int32_t IGUANA_NUMHELPERS = 1;
int32_t IGUANA_NUMHELPERS = 4;
#else
char GLOBAL_TMPDIR[512] = "tmp";
char GLOBAL_HELPDIR[512] = "help";
@ -1321,7 +1321,7 @@ void iguana_main(void *arg)
iguana_helpinit(myinfo);
iguana_commandline(myinfo,arg);
#ifdef __APPLE__
//iguana_appletests(myinfo);
iguana_appletests(myinfo);
#endif
iguana_launchdaemons(myinfo);
}

Loading…
Cancel
Save