Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
796481de35
  1. 5
      iguana/iguana777.h
  2. 26
      iguana/iguana_bundles.c
  3. 27
      iguana/iguana_recv.c

5
iguana/iguana777.h

@ -47,7 +47,7 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define IGUANA_MAXPENDINGREQUESTS 3
#define IGUANA_PENDINGREQUESTS 512
#define IGUANA_PENDINGREQUESTS 64
#define IGUANA_MINPENDBUNDLES 4
#define IGUANA_MAXPENDBUNDLES 16
#define IGUANA_RPCPORT 7778
@ -495,7 +495,7 @@ struct iguana_info
struct iguana_ramchain RTramchain; struct OS_memspace RTmem,RThashmem; bits256 RThash1;
int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime;
double backstopmillis; bits256 backstophash2; int64_t spaceused;
double bandwidth,maxbandwidth,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;
uint64_t bloomsearches,bloomhits,bloomfalse,collisions;
@ -882,6 +882,7 @@ int32_t iguana_voutsfname(struct iguana_info *coin,char *fname,int32_t slotid);
int32_t iguana_vinsfname(struct iguana_info *coin,char *fname,int32_t slotid);
bits256 iguana_merkle(struct iguana_info *coin,bits256 *tree,int32_t txn_count);
int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int32_t requiredflag);
int32_t iguana_blast(struct iguana_info *coin,int32_t modval);
extern int32_t HDRnet,netBLOCKS;

26
iguana/iguana_bundles.c

@ -623,6 +623,24 @@ int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle
return(n);
}
int32_t iguana_blast(struct iguana_info *coin,int32_t modval)
{
struct iguana_bundle *bp; int32_t i,range,n = 0;
if ( (bp= coin->current) != 0 && (range= (coin->bundlescount - bp->hdrsi)) > 0 )
{
modval %= range;
if ( (bp= coin->bundles[bp->hdrsi + modval]) != 0 )
{
for (i=0; i<bp->n; i++)
if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0;
n = iguana_bundleissuemissing(coin,bp,3,1.);
printf("blasted.%d -> [%d]\n",n,bp->hdrsi);
}
}
return(n);
}
int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int32_t requiredflag)
{
static bits256 zero;
@ -684,6 +702,7 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int
}
else
{
#ifndef __PNACL__
fname[0] = 0;
checki = iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,block->RO.hash2,zero,1,0);
if ( hdrsi == bp->hdrsi && checki == i && (fp= fopen(fname,"rb")) != 0 )
@ -695,7 +714,10 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int
ready++;
}
fclose(fp);
} else iguana_blockunmark(coin,block,bp,i,0);
}
else
#endif
iguana_blockunmark(coin,block,bp,i,0);
}
}
else if ( bp->queued != 0 )
@ -882,7 +904,7 @@ int32_t iguana_bundlefinalize(struct iguana_info *coin,struct iguana_bundle *bp,
/*if ( bp->hdrsi == 0 && iguana_peerblockrequest(coin,coin->blockspace,sizeof(coin->blockspace),0,bp->hashes[0],1) > 0 )
printf("GENESIS block validated\n");
else printf("GENESIS didnt validate bp.%p\n",bp);*/
iguana_bundlevalidate(coin,bp,1);
//iguana_bundlevalidate(coin,bp,1);
}
else
{

27
iguana/iguana_recv.c

@ -280,7 +280,7 @@ void iguana_bundletime(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen)
{
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag; struct iguana_block *block; struct iguana_bundle *bp; char str[65];
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65];
if ( 0 )
{
for (i=0; i<txdata->space[0]; i++)
@ -316,15 +316,32 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
origtxdata->block.txvalid = 1;
if ( addr != 0 && addr != &coin->internaladdr )
{
static uint64_t received[IGUANA_MAXPEERS],count[IGUANA_MAXPEERS];
static uint64_t received[IGUANA_MAXPEERS],count[IGUANA_MAXPEERS],lastcount,lastreceived,last;
received[addr->addrind] += recvlen;
count[addr->addrind]++;
if ( (rand() % 1000) == 0 )
now = (uint32_t)time(NULL);
if ( ((rand() % 100) == 0 && now > last+10) || now > last+60 )
{
uint64_t sum2 = 0,sum = 0;
int64_t sum2 = 0,sum = 0,diffr,diff; double bw = 0.;
for (i=0; i<sizeof(received)/sizeof(*received); i++)
sum += received[i], sum2 += count[i];
char str[65],str2[65],str3[65]; printf("%s TOTAL BLOCKS.%llu RECEIVED %s ave %.1f | duplicates.%d %s afteremit.%d %s\n",coin->symbol,(long long)sum2,mbstr(str,sum),(double)sum/(sum2!=0?sum2:1),numDuplicates,mbstr(str2,sizeDuplicates),numAfteremit,mbstr(str3,sizeAfteremit));
diffr = (sum - lastreceived), diff = (sum2 - lastcount);
//printf("diffr %d diff %d, last %d/%d\n",(int32_t)diffr,(int32_t)diff,(int32_t)lastreceived,(int32_t)lastcount);
lastreceived = sum, lastcount = sum2;
if ( diff != 0 )
{
bw = ((double)diffr / (now - last + 1));
if ( bw > coin->maxbandwidth )
coin->maxbandwidth = bw;
}
coin->bandwidth = bw;
if ( coin->bandwidth < 0.25*coin->maxbandwidth )
{
printf(">>SLOW<< ");
iguana_blast(coin,addr->addrind);
}
char str[65],str2[65],str3[65],str4[65]; printf("%s BLOCKS.%llu RECV %s ave %.1f | dup.%d %s after.%d %s %s/sec %.2f%%\n",coin->symbol,(long long)sum2,mbstr(str,sum),(double)sum/(sum2!=0?sum2:1),numDuplicates,mbstr(str2,sizeDuplicates),numAfteremit,mbstr(str3,sizeAfteremit),mbstr(str4,bw),coin->maxbandwidth!=0.?100.*coin->bandwidth/coin->maxbandwidth:0.);
last = now;
}
}
copyflag = 0;//(coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);

Loading…
Cancel
Save