Browse Source

test

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

8
iguana/iguana777.c

@ -345,12 +345,14 @@ int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *m
}
else if ( ptr->type == 'E' )
{
coin->emitbusy++;
if ( iguana_bundlesaveHT(coin,mem,memB,bp,ptr->starttime) == 0 )
{
//fprintf(stderr,"emitQ coin.%p bp.[%d]\n",ptr->coin,bp->bundleheight);
bp->emitfinish = (uint32_t)time(NULL) + 1;
coin->numemitted++;
} else bp->emitfinish = 0;
coin->emitbusy--;
}
} else printf("no bundle in helperrequest\n");
} else printf("no coin in helperrequest\n");
@ -379,7 +381,7 @@ void iguana_helper(void *arg)
allcurrent = 1;
if ( ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) )
{
if ( ptr->bp != 0 && (coin= ptr->coin) != 0 )
if ( ptr->bp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 )
{
idle = 0;
coin->helperdepth++;
@ -392,7 +394,7 @@ void iguana_helper(void *arg)
else if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
{
idle = 0;
if ( (bp= ptr->bp) != 0 && (coin= ptr->coin) != 0 )
if ( (bp= ptr->bp) != 0 && (coin= ptr->coin) != 0 && coin->active != 0 )
{
coin->numbundlesQ--;
if ( coin->started != 0 && time(NULL) >= bp->nexttime )
@ -408,7 +410,7 @@ void iguana_helper(void *arg)
{
if ( (ptr= queue_dequeue(&validateQ,0)) != 0 )
{
if ( ptr->bp != 0 && ptr->coin != 0 )
if ( ptr->bp != 0 && ptr->coin != 0 && coin->active != 0 )
flag += iguana_bundlevalidate(ptr->coin,ptr->bp);
else printf("helper validate missing param? %p %p\n",ptr->coin,ptr->bp);
myfree(ptr,ptr->allocsize);

2
iguana/iguana777.h

@ -465,7 +465,7 @@ struct iguana_info
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,estsize,activebundles;
int32_t MAXPEERS,MAXPENDING,MAXBUNDLES,active,closestbundle,numemitted,lastsweep,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,balanceswritten,RTheight; bits256 balancehash;
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog;
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy;
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy;
struct tai starttime; double startmillis;
struct iguana_chain *chain;
struct iguana_iAddr *iAddrs;

51
iguana/iguana_bundles.c

@ -670,7 +670,7 @@ int32_t iguana_setmaxbundles(struct iguana_info *coin)
{
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);
//printf("MAXBUNDLES %d (%d -> %d) completed %.3f\n",coin->MAXBUNDLES,coin->startPEND,coin->endPEND,completed);
}
return(coin->MAXBUNDLES);
}
@ -840,7 +840,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,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;
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; long lag;
if ( coin->started == 0 )
{
printf("%s not ready yet\n",coin->symbol);
@ -898,6 +898,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
iguana_emitQ(coin,bp);
else
{
coin->emitbusy++;
if ( iguana_bundlesaveHT(coin,mem,memB,bp,(uint32_t)time(NULL)) == 0 )
{
//fprintf(stderr,"emitQ done coin.%p bp.[%d] ht.%d\n",coin,bp->hdrsi,bp->bundleheight);
@ -909,6 +910,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
fprintf(stderr,"emitQ done coin.%p bp.[%d] ht.%d error\n",coin,bp->hdrsi,bp->bundleheight);
bp->emitfinish = 0;
}
coin->emitbusy--;
}
}
retval = 1;
@ -925,30 +927,35 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
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 )
{
if ( time(NULL)-coin->stucktime == IGUANA_MAXSTUCKTIME/2 )
lag = time(NULL)-coin->stucktime;
if ( lag == IGUANA_MAXSTUCKTIME/2 || lag == 3*IGUANA_MAXSTUCKTIME/4 )
{
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) )
if ( lag > IGUANA_MAXSTUCKTIME/2 )
{
struct iguana_blockreq *breq;
while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 )
myfree(breq,sizeof(*breq));
while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 )
myfree(breq,sizeof(*breq));
}
for (i=n=0; i<bp->n; i++)
{
printf("[%d:%d] ",bp->hdrsi,i);
iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,1);
if ( coin->peers.numranked > 8 && (addr= coin->peers.ranked[n % 8]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack != 0 )
if ( (block= bp->blocks[i]) != 0 && (block->RO.recvlen == 0 || block->fpos < 0 || block->fpipbits == 0 || bits256_nonz(block->RO.prev_block) == 0) )
{
if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,&block->RO.hash2,1)) > 0 )
printf("[%d:%d] ",bp->hdrsi,i);
iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,1);
if ( coin->peers.numranked > 8 && (addr= coin->peers.ranked[n % 8]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack != 0 )
{
printf("%s, ",addr->ipaddr);
iguana_send(coin,addr,serialized,len);
if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,&block->RO.hash2,1)) > 0 )
{
printf("%s, ",addr->ipaddr);
iguana_send(coin,addr,serialized,len);
}
}
n++;
}
n++;
}
}
printf("issued %d priority requests [%d] to unstick\n",n,bp->hdrsi);
}
else if ( time(NULL)-coin->stucktime == 3*IGUANA_MAXSTUCKTIME/4 )
{
printf("issued %d priority requests [%d] to unstick\n",n,bp->hdrsi);
}
}
}
@ -1046,7 +1053,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
if ( (block= bp->blocks[j]) != 0 && (block->RO.recvlen == 0 || block->fpipbits == 0 || block->fpos < 0) && time(NULL) > block->issued+3 && (rand() % 10) == 0 )
{
if ( (r= coin->peers.numranked) != 0 && (addr= coin->peers.ranked[rand() % r]) != 0 && addr->dead == 0 && addr->usock >= 0 )
iguana_sendblockreqPT(coin,addr,bp,j,block->RO.hash2,0); printf("current stop [%d:%d]\n",bp->hdrsi,j);
iguana_sendblockreqPT(coin,addr,bp,j,block->RO.hash2,0); printf("kick [%d:%d]\n",bp->hdrsi,j);
iguana_blockQ("currentstop",coin,bp,j,block->RO.hash2,1);
block->issued = (uint32_t)time(NULL);
break;
@ -1113,7 +1120,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
free(sortbuf);*/
coin->numremain = n;
coin->blocksrecv = numrecv;
char str2[65]; uint64_t tmp; int32_t diff,p = 0; struct tai difft,t = tai_now();
uint64_t tmp; int32_t diff,p = 0; struct tai difft,t = tai_now();
for (i=0; i<IGUANA_MAXPEERS; i++)
if ( coin->peers.active[i].usock >= 0 )
p++;
@ -1144,7 +1151,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
}
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,"%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 maxB.%d 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->MAXBUNDLES,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 )
{

4
iguana/iguana_init.c

@ -391,9 +391,9 @@ void iguana_coinpurge(struct iguana_info *coin)
myfree(req->hashes,sizeof(*req->hashes) * req->n), req->hashes = 0;
myfree(req,req->allocsize);
}
while ( coin->idletime == 0 )
while ( coin->idletime == 0 && coin->emitbusy > 0 )
{
printf("coinpurge.%s waiting for idle %lu\n",coin->symbol,time(NULL));
printf("coinpurge.%s waiting for idle %lu emitbusy.%d\n",coin->symbol,time(NULL),coin->emitbusy);
sleep(1);
}
iguana_RTramchainfree(coin);

8
iguana/iguana_ramchain.c

@ -1650,6 +1650,8 @@ int32_t iguana_ramchain_iterate(struct iguana_info *coin,struct iguana_ramchain
}
for (ramchain->H.txidind=rdata->firsti; ramchain->H.txidind<rdata->numtxids; ramchain->H.txidind++)
{
if ( coin->active == 0 )
return(-1);;
if ( 0 && ramchain->expanded == 0 && dest != 0 )
printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",ramchain->H.data->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids);
tx = &T[ramchain->H.txidind];
@ -1665,6 +1667,8 @@ int32_t iguana_ramchain_iterate(struct iguana_info *coin,struct iguana_ramchain
}
for (j=0; j<tx->numvouts; j++)
{
if ( coin->active == 0 )
return(-1);
fileid = 0;
scriptpos = 0;
scriptlen = 0;
@ -1744,6 +1748,8 @@ int32_t iguana_ramchain_iterate(struct iguana_info *coin,struct iguana_ramchain
tx = &T[ramchain->H.txidind];
for (j=0; j<tx->numvins; j++)
{
if ( coin->active == 0 )
return(-1);
fileid = 0;
scriptpos = 0;
scriptlen = 0;
@ -2482,6 +2488,8 @@ int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,str
dest->H.scriptoffset = 1;
for (bundlei=starti; bundlei<=endi; bundlei++)
{
if ( coin->active == 0 )
break;
if ( (block= bp->blocks[bundlei]) != 0 )
{
iguana_blocksetcounters(coin,block,dest);

2
iguana/main.c

@ -377,7 +377,9 @@ void mainloop(struct supernet_info *myinfo)
{
printf("%s is stuck too long, restarting\n",coin->symbol);
iguana_coinpurge(coin);
sleep(5);
coin->active = 1;
sleep(5);
}
coin->RTramchain_busy = (coin->RTgenesis == 0 || queue_size(&balancesQ) != 0);
}

Loading…
Cancel
Save