Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
8e6f977dda
  1. 3
      iguana/iguana777.h
  2. 55
      iguana/iguana_bundles.c
  3. 1
      iguana/iguana_init.c
  4. 2
      iguana/iguana_ramchain.c
  5. 9
      iguana/iguana_unspents.c
  6. 6
      iguana/main.c

3
iguana/iguana777.h

@ -26,6 +26,7 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
#define IGUANA_SERIALIZE_SPENDVECTORGEN
//#define IGUANA_SERIALIZE_BALANCEGEN
//#define IGUANA_DISABLEPEERS
#define IGUANA_MAXSTUCKTIME 77
#define IGUANA_MAXCOINS 64
#define IGUANA_MAXDELAY_MILLIS (3600 * 1000)
@ -480,7 +481,7 @@ struct iguana_info
struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending;
struct iguana_ramchain RTramchain; struct OS_memspace RTmem,RThashmem;
int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,idletime;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,idletime,stucktime,stuckmonitor,maxstuck;
double backstopmillis; bits256 backstophash2; int64_t spaceused;
int32_t initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,polltimeout,numreqtxids,allhashes; bits256 reqtxids[64];
void *launched,*started;

55
iguana/iguana_bundles.c

@ -665,18 +665,24 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
int32_t iguana_bundletweak(struct iguana_info *coin,struct iguana_bundle *bp)
{
struct iguana_bundle *lastbp;
struct iguana_bundle *lastbp; double completed;
if ( coin->current == bp )
coin->current = coin->bundles[bp->hdrsi+1];
if ( (lastbp= coin->lastpending) != 0 && lastbp->hdrsi < coin->bundlescount-1 )
coin->lastpending = coin->bundles[lastbp->hdrsi + 1];
if ( (rand() % 3) == 0 )
if ( coin->current != 0 && coin->bundlescount != 0 )
{
completed = ((double)coin->current->hdrsi + 1) / coin->bundlescount;
coin->MAXBUNDLES = (double)(coin->endPEND - coin->startPEND)*completed + coin->startPEND;
printf("MAXBUNDLES %d (%d -> %d) completed %.3f\n",coin->MAXBUNDLES,coin->startPEND,coin->endPEND,completed);
}
/*if ( (rand() % 3) == 0 )
{
if ( coin->MAXBUNDLES > coin->endPEND )
coin->MAXBUNDLES--;
else if ( coin->MAXBUNDLES < coin->endPEND )
coin->MAXBUNDLES++;
}
}*/
return(coin->MAXBUNDLES);
}
@ -704,7 +710,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
printf("iguana_bundlecalcs.(%s) illegal hdrsi.%d bundlei.%d checki.%d\n",fname,hdrsi,bundlei,checki);
continue;
}
if ( coin->current == bp )
if ( coin->current == bp && bp->isRT != 0 )
{
if ( (fp= fopen(fname,"rb")) != 0 )
{
@ -827,7 +833,7 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,int32_t timelimit)
{
int32_t range,starti,lasti,retval=0,max,counter = 0; struct iguana_bundle *currentbp,*lastbp;
int32_t range,starti,lasti,i,n,len,retval=0,max,counter = 0; struct iguana_block *block; struct iguana_bundle *currentbp,*lastbp; uint8_t serialized[512]; struct iguana_peer *addr;
if ( coin->started == 0 )
{
printf("%s not ready yet\n",coin->symbol);
@ -868,7 +874,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
} //else printf("finish incomplete.%d\n",bp->hdrsi);
}
}
else if ( bp->numsaved >= bp->n )
else if ( bp->numsaved >= bp->n && (bp->isRT == 0 || coin->RTheight > bp->bundleheight+bp->n+coin->minconfirms) )
{
if ( iguana_bundleready(coin,bp) == bp->n )
{
@ -906,8 +912,31 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
counter = iguana_bundleissue(coin,bp,max,timelimit);
if ( bp == coin->current && coin->isRT == 0 )
bp->nexttime--;
if ( bp->hdrsi == starti && counter > 0 )
if ( bp->hdrsi == starti )
{
printf("ITER now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount);
if ( coin->stucktime != 0 && time(NULL)-coin->stucktime == IGUANA_MAXSTUCKTIME/2 )
{
for (i=n=0; i<bp->n; i++)
{
if ( (block= bp->blocks[i]) != 0 && (block->RO.recvlen == 0 || block->fpos < 0 || block->fpipbits == 0 || bits256_nonz(block->RO.prev_block) == 0) )
{
printf("[%d:%d] ",bp->hdrsi,i);
iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,1);
if ( (addr= coin->peers.ranked[n % 8]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack != 0 )
{
if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,&block->RO.hash2,1)) > 0 )
{
printf("%s, ",addr->ipaddr);
iguana_send(coin,addr,serialized,len);
}
}
n++;
}
}
printf("issued %d priority requests [%d] to unstick\n",bp->hdrsi,n);
}
}
}
iguana_bundleQ(coin,bp,1000);
return(retval);
@ -1090,11 +1119,21 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
coin->spaceused = spaceused;
coin->numverified = numv;
char str4[65],str5[65];
if ( firstgap != 0 && firstgap->hdrsi < coin->bundlescount-1 )
{
if ( coin->stuckmonitor != (firstgap->hdrsi * coin->chain->bundlesize) + firstgap->numsaved )
{
coin->stuckmonitor = (firstgap->hdrsi * coin->chain->bundlesize) + firstgap->numsaved;
coin->stucktime = (uint32_t)time(NULL);
}
}
if ( coin->stucktime != 0 && time(NULL)-coin->stucktime > coin->maxstuck )
coin->maxstuck = (uint32_t)time(NULL) - coin->stucktime;
sprintf(str,"%s.RT%d u.%d b.%d v.%d/%d (%d/%d 1st.%d) to %d N[%d] h.%d r.%d c.%s s.%d d.%d E.%d:%d est.%d %s peers.%d/%d Q.(%d %d) L.%d [%d:%d] M.%d %s",coin->symbol,coin->RTheight,numutxo,numbalances,numv,coin->pendbalances,firstgap!=0?firstgap->numsaved:-1,firstgap!=0?firstgap->numhashes:-1,firstgap!=0?firstgap->hdrsi:-1,coin->lastpending!=0?coin->lastpending->hdrsi:0,count,numhashes,coin->blocksrecv,mbstr(str4,spaceused),numsaved,done,numemit,coin->numreqsent,coin->MAXBUNDLES,mbstr(str2,estsize),p,coin->MAXPEERS,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ),coin->longestchain,coin->blocks.hwmchain.height/coin->chain->bundlesize,coin->blocks.hwmchain.height%coin->chain->bundlesize,coin->blocks.hwmchain.height,bits256_str(str5,coin->blocks.hwmchain.RO.hash2));
//sprintf(str+strlen(str),"%s.%-2d %s time %.2f files.%d Q.%d %d\n",coin->symbol,flag,str,(double)(time(NULL)-coin->starttime)/60.,coin->peers.numfiles,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ));
if ( time(NULL) > coin->lastdisp+3 && strcmp(str,coin->lastdispstr) != 0 )
{
printf("\n%s bQ.%d %d:%02d:%02d %03.3f\n",str,coin->numbundlesQ,(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,difft.millis);
printf("\n%s bQ.%d %d:%02d:%02d stuck.%d max.%d\n",str,coin->numbundlesQ,(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,(uint32_t)time(NULL) - coin->stucktime,coin->maxstuck);
strcpy(coin->lastdispstr,str);
if ( (rand() % 100) == 0 )
myallocated(0,0);

1
iguana/iguana_init.c

@ -374,6 +374,7 @@ void iguana_coinpurge(struct iguana_info *coin)
{
int32_t i; struct iguana_bundle *bp; char *hashstr; struct iguana_bundlereq *req; struct iguana_blockreq *breq;
coin->started = 0; coin->active = 0;
coin->RTgenesis = 0;
while ( (hashstr= queue_dequeue(&coin->hdrsQ,1)) != 0 )
free_queueitem(hashstr);
while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 )

2
iguana/iguana_ramchain.c

@ -1873,7 +1873,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru
{
origtxdata->block.issued = 0;
origtxdata->block.RO.recvlen = 0;
printf("ramchain data: error finding block\n");
char str[65]; printf("ramchain data: error finding block %s\n",bits256_str(str,origtxdata->block.RO.hash2));
return(-1);
}
}

9
iguana/iguana_unspents.c

@ -911,9 +911,10 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t bundlei,err,n,flag=0;
struct iguana_block *block=0; struct iguana_blockRO *B; struct iguana_ramchain *dest=0,blockR;
long filesize; void *ptr; char str[65],fname[1024];
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 )
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->blocks.hwmchain.height >= coin->longestchain-1 )
{
iguana_RTramchainalloc(coin,bp);
bp->isRT = 1;
while ( (rdata= coin->RTramchain.H.data) != 0 && coin->RTheight <= coin->blocks.hwmchain.height)
{
dest = &coin->RTramchain;
@ -982,9 +983,9 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
}
}
}
if ( dest != 0 && flag != 0 )
{
n = 0;
if ( dest != 0 && flag != 0 && coin->RTheight >= coin->longestchain )
{
while ( block != 0 )
{
if ( bits256_cmp(iguana_blockhash(coin,coin->RTheight-n-1),block->RO.hash2) != 0 )
@ -1002,8 +1003,8 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
printf("RTgenesis verified\n");
coin->RTgenesis = (uint32_t)time(NULL);
}
printf(">>>> RT.%d:%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",coin->RTheight,n,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,(long)dest->H.data->allocsize);
}
printf(">>>> RT.%d:%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",coin->RTheight,n,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,(long)dest->H.data->allocsize);
return(0);
}

6
iguana/main.c

@ -373,6 +373,12 @@ void mainloop(struct supernet_info *myinfo)
}
myfree(ptr,ptr->allocsize);
}
if ( coin->isRT == 0 && coin->RTheight == 0 && (time(NULL) - coin->stucktime) > IGUANA_MAXSTUCKTIME )
{
printf("%s is stuck too long, restarting\n",coin->symbol);
iguana_coinpurge(coin);
coin->active = 1;
}
coin->RTramchain_busy = (coin->RTgenesis == 0 || queue_size(&balancesQ) != 0);
}
}

Loading…
Cancel
Save