Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
d375d1911f
  1. 4
      iguana/iguana777.c
  2. 47
      iguana/iguana_recv.c

4
iguana/iguana777.c

@ -376,8 +376,8 @@ void iguana_helper(void *arg)
} }
} }
if ( flag == 0 ) if ( flag == 0 )
usleep(500000); usleep(1000000);
else usleep(5000); else usleep(100000);
} }
} }

47
iguana/iguana_recv.c

@ -423,9 +423,9 @@ int32_t iguana_bundlekick(struct iguana_info *coin,struct iguana_bundle *bp,int3
{ {
if ( (block= bp->blocks[i]) != 0 ) if ( (block= bp->blocks[i]) != 0 )
{ {
if ( block->fpipbits == 0 )//|| block->RO.recvlen == 0 ) if ( block->fpipbits == 0 || block->RO.recvlen == 0 )
{ {
if ( bp->numsaved > bp->n*.95 || block->issued == 0 || now > block->issued+60 ) if ( block->issued == 0 || now > block->issued+60 )
{ {
block->numrequests++; block->numrequests++;
if ( bp->hdrsi == starti ) if ( bp->hdrsi == starti )
@ -434,8 +434,7 @@ int32_t iguana_bundlekick(struct iguana_info *coin,struct iguana_bundle *bp,int3
if ( coin->peers.ranked[0] != 0 ) if ( coin->peers.ranked[0] != 0 )
iguana_sendblockreqPT(coin,coin->peers.ranked[0],bp,i,block->RO.hash2,0); iguana_sendblockreqPT(coin,coin->peers.ranked[0],bp,i,block->RO.hash2,0);
iguana_blockQ(coin,bp,i,block->RO.hash2,1); iguana_blockQ(coin,bp,i,block->RO.hash2,1);
} } else iguana_blockQ(coin,bp,i,block->RO.hash2,0);
iguana_blockQ(coin,bp,i,block->RO.hash2,0);
bp->issued[i] = block->issued = now; bp->issued[i] = block->issued = now;
counter++; counter++;
if ( --max <= 0 ) if ( --max <= 0 )
@ -453,7 +452,7 @@ int32_t iguana_bundlekick(struct iguana_info *coin,struct iguana_bundle *bp,int3
int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit)
{ {
int32_t i,r,range,starti,lasti,numhashes,issued,valid,max,counter = 0; struct iguana_block *block; double endmillis,width; struct iguana_bundle *prevbp,*currentbp,*lastbp; uint32_t starttime; int32_t i,r,range,starti,pend,better,lasti,numhashes,issued,valid,max,counter = 0; struct iguana_block *block; double endmillis,width; struct iguana_bundle *prevbp,*currentbp,*lastbp; uint32_t starttime;
if ( (range= coin->peers.numranked) > coin->MAXBUNDLES ) if ( (range= coin->peers.numranked) > coin->MAXBUNDLES )
range = coin->MAXBUNDLES; range = coin->MAXBUNDLES;
currentbp = coin->current; currentbp = coin->current;
@ -559,41 +558,35 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int
iguana_bundleQ(coin,bp,1000); iguana_bundleQ(coin,bp,1000);
return(0); return(0);
} }
//printf("initial requests for hdrs.%d\n",bp->hdrsi); if ( bp != currentbp )
/*pend = queue_size(&coin->priorityQ) + queue_size(&coin->blocksQ);
for (i=0; i<IGUANA_MAXPEERS; i++)
pend += coin->peers.active[i].pendblocks;
if ( pend >= coin->MAXPENDING*coin->peers.numranked )
{ {
for (i=better=0; i<coin->bundlescount; i++) //printf("initial requests for hdrs.%d\n",bp->hdrsi);
if ( coin->bundles[i] != 0 && coin->bundles[i]->numsaved > bp->numsaved ) pend = queue_size(&coin->priorityQ) + queue_size(&coin->blocksQ);
better++; for (i=0; i<IGUANA_MAXPEERS; i++)
if ( better > coin->peers.numranked ) pend += coin->peers.active[i].pendblocks;
if ( pend >= coin->MAXPENDING*coin->peers.numranked )
{ {
usleep(10000); for (i=better=0; i<coin->bundlescount; i++)
//printf("SKIP pend.%d vs %d: better.%d ITERATE bundle.%d n.%d r.%d s.%d finished.%d timelimit.%d\n",pend,coin->MAXPENDING*coin->peers.numranked,better,bp->bundleheight,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit); if ( coin->bundles[i] != 0 && coin->bundles[i]->numsaved > bp->numsaved )
iguana_bundleQ(coin,bp,counter == 0 ? bp->n*5 : bp->n*2); better++;
return(0); if ( better > coin->peers.numranked )
{
usleep(10000);
//printf("SKIP pend.%d vs %d: better.%d ITERATE bundle.%d n.%d r.%d s.%d finished.%d timelimit.%d\n",pend,coin->MAXPENDING*coin->peers.numranked,better,bp->bundleheight,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit);
iguana_bundleQ(coin,bp,counter == 0 ? bp->n*5 : bp->n*2);
return(0);
}
} }
} }
max = 1 + ((coin->MAXPENDING*coin->MAXPEERS - pend) >> 1);*/
issued = 0; issued = 0;
max = 100 + (bp->n/coin->MAXBUNDLES)*(bp->hdrsi - starti); max = 100 + (bp->n/coin->MAXBUNDLES)*(bp->hdrsi - starti);
iguana_bundlekick(coin,bp,starti,max); iguana_bundlekick(coin,bp,starti,max);
if ( 0 && currentbp != 0 && queue_size(&coin->blocksQ) == 0 )
iguana_bundlekick(coin,currentbp,starti,max);
if ( coin->numsaved > coin->longestchain*.99 ) if ( coin->numsaved > coin->longestchain*.99 )
{ {
printf("last percent via hdrsi.%d\n",bp->hdrsi); printf("last percent via hdrsi.%d\n",bp->hdrsi);
for (r=starti; r<coin->bundlescount; r++) for (r=starti; r<coin->bundlescount; r++)
iguana_bundlekick(coin,coin->bundles[r],r,coin->bundles[r]->n); iguana_bundlekick(coin,coin->bundles[r],r,coin->bundles[r]->n);
} }
else if ( 0 )
{
r = (rand() % 7);
if ( starti+r < coin->bundlescount && coin->bundles[starti+r] != 0 )
iguana_bundlekick(coin,coin->bundles[starti+r],starti+r,coin->bundles[starti+r]->n);
}
endmillis = OS_milliseconds() + timelimit + (rand() % 1000); endmillis = OS_milliseconds() + timelimit + (rand() % 1000);
if ( bp->numsaved < bp->n ) if ( bp->numsaved < bp->n )
width = 100 + max*100;//sqrt(sqrt(bp->n * (1+bp->numsaved+issued)) * (10+coin->bundlescount-bp->hdrsi)); width = 100 + max*100;//sqrt(sqrt(bp->n * (1+bp->numsaved+issued)) * (10+coin->bundlescount-bp->hdrsi));

Loading…
Cancel
Save