Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
ebd20009ae
  1. 67
      iguana/iguana777.c
  2. 21
      iguana/iguana_bundles.c
  3. 57
      iguana/iguana_recv.c

67
iguana/iguana777.c

@ -379,9 +379,9 @@ void iguana_helper(void *arg)
struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp;
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
helperid = juint(argjson,"helperid");
if ( IGUANA_NUMHELPERS < 3 )
type = 7;
else type = (1 << (helperid % 3));
if ( IGUANA_NUMHELPERS < 2 )
type = 3;
else type = (1 << (helperid % 2));
if ( argjson != 0 )
free_json(argjson);
printf("HELPER.%d started arg.(%s) type.%d\n",helperid,(char *)(arg!=0?arg:0),type);
@ -406,28 +406,40 @@ void iguana_helper(void *arg)
flag++;
}
myfree(ptr,ptr->allocsize);
}*/
if ( (type & (1 << 0)) != 0 && (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
}*/
if ( (type & (1 << 0)) != 0 )
{
//printf("bundleQ size.%d\n",queue_size(&bundlesQ));
idle = 0;
coin = ptr->coin;
if ( (bp= ptr->bp) != 0 && coin != 0 )
if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
{
coin->numbundlesQ--;
if ( coin->started != 0 && time(NULL) >= bp->nexttime && coin->active != 0 )
flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,bp,ptr->timelimit);
else
idle = 0;
coin = ptr->coin;
if ( (bp= ptr->bp) != 0 && coin != 0 )
{
//printf("skip.%d lag.%ld coin->active.%d\n",bp->hdrsi,time(NULL)-bp->nexttime,coin->active);
iguana_bundleQ(ptr->coin,bp,1000);
//printf("[%d] bundleQ size.%d\n",bp->hdrsi,queue_size(&bundlesQ));
coin->numbundlesQ--;
if ( coin->started != 0 && time(NULL) >= bp->nexttime && coin->active != 0 )
flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,bp,ptr->timelimit);
else
{
//printf("skip.%d lag.%ld coin->active.%d\n",bp->hdrsi,time(NULL)-bp->nexttime,coin->active);
iguana_bundleQ(ptr->coin,bp,1000);
}
if ( coin->current != 0 && coin->current->hdrsi != coin->bundlescount-1 )
allcurrent = 0;
}
if ( coin->current != 0 && coin->current->hdrsi != coin->bundlescount-1 )
allcurrent = 0;
else //if ( coin->active != 0 )
printf("helper missing param? %p %p %u\n",ptr->coin,bp,ptr->timelimit);
myfree(ptr,ptr->allocsize);
}
else if ( (ptr= queue_dequeue(&validateQ,0)) != 0 )
{
if ( ptr->bp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 )
flag += iguana_bundlevalidate(ptr->coin,ptr->bp);
else if ( coin->active != 0 )
printf("helper validate missing param? %p %p\n",ptr->coin,ptr->bp);
myfree(ptr,ptr->allocsize);
flag++;
}
else //if ( coin->active != 0 )
printf("helper missing param? %p %p %u\n",ptr->coin,bp,ptr->timelimit);
myfree(ptr,ptr->allocsize);
}
if ( (type & (1 << 1)) != 0 && (ptr= queue_dequeue(&spendvectorsQ,0)) != 0 )
{
@ -453,20 +465,11 @@ void iguana_helper(void *arg)
printf("helper missing param? %p %p\n",coin,bp);
myfree(ptr,ptr->allocsize);
}
if ( (type & (1 << 2)) != 0 && (ptr= queue_dequeue(&validateQ,0)) != 0 )
{
if ( ptr->bp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 )
flag += iguana_bundlevalidate(ptr->coin,ptr->bp);
else if ( coin->active != 0 )
printf("helper validate missing param? %p %p\n",ptr->coin,ptr->bp);
myfree(ptr,ptr->allocsize);
flag++;
}
if ( flag == 0 )
usleep(100000);
else if ( allcurrent != 0 )
usleep(25000);
else usleep(2500);
else if ( allcurrent != 0 )
usleep(100000);
else usleep(10000);
}
}

21
iguana/iguana_bundles.c

@ -634,17 +634,17 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
{
int32_t counter=0;
int32_t i; uint32_t now; struct iguana_block *block;
if ( bp->hdrsi == coin->bundlescount-1 || bp == coin->current )
printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec);
if ( coin->enableCACHE != 0 && bp->numhashes < bp->n )
{
char str[64];
if ( bp->hdrsi == coin->bundlescount-1 || bp == coin->current )
printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
}
if ( bp->speculative != 0 && bp == coin->current )
{
now = (uint32_t)time(NULL);
for (i=0; i<bp->numspec; i++)
for (i=0; i<bp->numspec&&i<bp->n; i++)
{
if ( bits256_nonz(bp->hashes[i]) == 0 && bits256_nonz(bp->speculative[i]) != 0 )
{
@ -833,7 +833,8 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
iguana_balancesQ(coin,bp);
}
return(1);
} // else printf("%u notready postfinish.%d startutxo.%u prevbp.%d %u current.%d\n",(uint32_t)time(NULL),bp->hdrsi,bp->startutxo,prevbp!=0?prevbp->hdrsi:-1,prevbp!=0?prevbp->emitfinish:0,coin->current!=0?coin->current->hdrsi:-1);
}
// else printf("%u notready postfinish.%d startutxo.%u prevbp.%d %u current.%d\n",(uint32_t)time(NULL),bp->hdrsi,bp->startutxo,prevbp!=0?prevbp->hdrsi:-1,prevbp!=0?prevbp->emitfinish:0,coin->current!=0?coin->current->hdrsi:-1);
return(0);
}
@ -868,12 +869,18 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
iguana_bundlehdr(coin,bp,starti);
else if ( bp->emitfinish != 0 )
{
//printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(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 ( bp->utxofinish != 0 )
{
if ( bp->balancefinish == 0 )
iguana_balancesQ(coin,bp);
return(1);
}
if ( bp->emitfinish > 1 )
{
//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 ( (retval= iguana_bundlefinish(coin,bp)) > 0 )
{
//printf("moved to balancesQ.%d bundleiters.%d\n",bp->hdrsi,bp->bundleheight);
printf("moved to balancesQ.%d bundleiters.%d\n",bp->hdrsi,bp->bundleheight);
bp->queued = 0;
return(0);
} //else printf("finish incomplete.%d\n",bp->hdrsi);
@ -1198,7 +1205,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
coin->stucktime = coin->stuckiters = 0;
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 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,"%s.RT%d u.%d b.%d v.%d/%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->numcached:-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 || time(NULL) > coin->lastdisp+60) )
{

57
iguana/iguana_recv.c

@ -194,6 +194,46 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
}
else if ( 0 && coin->enableCACHE != 0 )
printf("cache.%d validated.(%s)\n",coin->enableCACHE,bits256_str(str,origtxdata->block.RO.hash2));
if ( (bp= coin->current) != 0 )
{
while ( bp != 0 && bp->hdrsi < coin->bundlescount )
{
//struct iguana_block *block;
if ( bp->speculative != 0 )
{
for (i=1; i<bp->n; i++)
{
if ( bits256_cmp(bp->speculative[i],origtxdata->block.RO.hash2) == 0 )
{
if ( bits256_cmp(bp->hashes[i-1],origtxdata->block.RO.prev_block) == 0 )
{
//block->bundlei = i;
//block->hdrsi = bp->hdrsi;
//bp->blocks[i] = block;
printf("cache bundlehashadd set.%d\n",i);
iguana_bundlehash2add(coin,0,bp,i,origtxdata->block.RO.hash2);
//if ( block->req != 0 )
{
printf("cacheQ ");
//queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0);
//block->req = 0;
}
}
printf("speculative recv.[%d:%d] numcached.%d\n",bp->hdrsi,i,bp->numcached);
bp = 0;
break;
}
}
}
if ( bp != 0 )
{
if ( bp->hdrsi < coin->bundlescount-1 )
bp = coin->bundles[bp->hdrsi + 1];
else bp = 0;
}
}
bp = 0;
}
copyflag = coin->enableCACHE;
bp = 0, bundlei = -2;
bp = iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.hash2);
@ -736,23 +776,6 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundlereq *req,struct iguana_block *origblock,int32_t numtx,int32_t datalen,int32_t recvlen,int32_t *newhwmp)
{
struct iguana_bundle *bp=0; int32_t i,width,numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock,*prev; char str[65];
if ( (bp= coin->current) != 0 && bp->speculative != 0 )
{
for (i=0; i<bp->n; i++)
if ( bits256_cmp(bp->speculative[i],origblock->RO.hash2) == 0 )
{
if ( (block= iguana_blockfind(coin,origblock->RO.hash2)) != 0 )
{
if ( req->copyflag != 0 )
{
block->queued = 1; // this prevents it from being used
block->req = req;
printf("CACHED ");
}
}
printf("speculative recv.[%d:%d]\n",bp->hdrsi,i);
}
}
if ( (bp= iguana_bundleset(coin,&block,&bundlei,origblock)) == 0 )
{
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,origblock->RO.prev_block)) != 0 )

Loading…
Cancel
Save