Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
9820c883e0
  1. 4
      iguana/iguana777.h
  2. 2
      iguana/iguana_bundles.c
  3. 19
      iguana/iguana_recv.c
  4. 23
      iguana/iguana_unspents.c

4
iguana/iguana777.h

@ -23,7 +23,7 @@
typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t len); typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t len);
#define IGUANA_MAXSCRIPTSIZE 10001 #define IGUANA_MAXSCRIPTSIZE 10001
#define IGUANA_SERIALIZE_SPENDVECTORGEN //#define IGUANA_SERIALIZE_SPENDVECTORGEN
//#define IGUANA_SERIALIZE_BALANCEGEN //#define IGUANA_SERIALIZE_BALANCEGEN
//#define IGUANA_DISABLEPEERS //#define IGUANA_DISABLEPEERS
#define _IGUANA_MAXSTUCKTIME 3600 #define _IGUANA_MAXSTUCKTIME 3600
@ -382,7 +382,7 @@ struct iguana_ramchain
{ {
struct iguana_ramchain_hdr H; bits256 lasthash2; uint64_t datasize,allocatedA,allocatedU; struct iguana_ramchain_hdr H; bits256 lasthash2; uint64_t datasize,allocatedA,allocatedU;
uint32_t numblocks:31,expanded:1,pkind,externalind,height,numXspends; uint32_t numblocks:31,expanded:1,pkind,externalind,height,numXspends;
long sparsesearches,sparseiters,sparsehits,sparsemax; long sparseadds,sparsesearches,sparseadditers,sparsesearchiters,sparsehits,sparsemax;
struct iguana_kvitem *txids,*pkhashes; struct iguana_kvitem *txids,*pkhashes;
struct OS_memspace *hashmem; long filesize,sigsfilesize,debitsfilesize,lastspendsfilesize; struct OS_memspace *hashmem; long filesize,sigsfilesize,debitsfilesize,lastspendsfilesize;
void *fileptr,*sigsfileptr,*Xspendptr,*debitsfileptr,*lastspendsfileptr; void *fileptr,*sigsfileptr,*Xspendptr,*debitsfileptr,*lastspendsfileptr;

2
iguana/iguana_bundles.c

@ -634,7 +634,7 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
{ {
int32_t counter=0; int32_t counter=0;
int32_t i; uint32_t now; struct iguana_block *block; int32_t i; uint32_t now; struct iguana_block *block;
if ( bp->hdrsi == coin->bundlescount-1 || bp == coin->current ) if ( bp->isRT == 0 && (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); 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 ) if ( coin->enableCACHE != 0 && bp->numhashes < bp->n )
{ {

19
iguana/iguana_recv.c

@ -159,6 +159,7 @@ struct iguana_txblock *iguana_peertxdata(struct iguana_info *coin,int32_t *bundl
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) 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)
{ {
static uint64_t received[IGUANA_MAXPEERS];
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,i,j,bundlei,copyflag; struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,i,j,bundlei,copyflag;
struct iguana_bundle *bp; struct iguana_bundle *bp;
if ( 0 ) if ( 0 )
@ -186,7 +187,15 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
} }
} }
} }
received[addr->addrind] += recvlen;
char str[65]; char str[65];
if ( (rand() % 1000) == 0 )
{
uint64_t sum = 0;
for (i=0; i<sizeof(received)/sizeof(*received); i++)
sum += received[i];
printf("TOTAL RECEIVED %s\n",mbstr(str,sum));
}
if ( iguana_blockvalidate(coin,&valid,&origtxdata->block,1) < 0 ) if ( iguana_blockvalidate(coin,&valid,&origtxdata->block,1) < 0 )
{ {
printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->block.RO.hash2)); printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->block.RO.hash2));
@ -331,6 +340,16 @@ void iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,struct
struct iguana_bundlereq *req; struct iguana_bundlereq *req;
if ( addr != 0 ) if ( addr != 0 )
{ {
static uint32_t hdrsreceived[IGUANA_MAXPEERS];
hdrsreceived[addr->addrind] += n;
char str[65];
if ( (rand() % 1000) == 0 )
{
uint32_t i,sum = 0;
for (i=0; i<sizeof(hdrsreceived)/sizeof(*hdrsreceived); i++)
sum += hdrsreceived[i];
printf("TOTAL HRS RECEIVED %u -> %s\n",sum,mbstr(str,sum*80));
}
addr->recvhdrs++; addr->recvhdrs++;
if ( addr->pendhdrs > 0 ) if ( addr->pendhdrs > 0 )
addr->pendhdrs--; addr->pendhdrs--;

23
iguana/iguana_unspents.c

@ -185,9 +185,11 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
} }
printf("tableentries.%d\n",n); printf("tableentries.%d\n",n);
} }
ramchain->sparsesearches++; if ( setind == 0 )
if ( (ramchain->sparsesearches % 1000000) == 0 ) ramchain->sparsesearches++;
printf("[%3d] %7d.[%-2d %8d] %5.3f sparse searches.%-10ld iters.%-10ld hits.%-10ld %5.2f%% max.%ld\n",ramchain->height/ramchain->H.data->numblocks,ramchain->height,width,tablesize,(double)ramchain->sparseiters/(1+ramchain->sparsesearches),ramchain->sparsesearches,ramchain->sparseiters,ramchain->sparsehits,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1); else ramchain->sparseadds++;
//if ( (ramchain->sparsesearches % 1000000) == 0 )
printf("[%3d] %7d.[%-2d %8d] %5.3f adds.(%-10ld %10ld) search.(hits.%-10ld %10ld) %5.2f%% max.%ld\n",ramchain->height/ramchain->H.data->numblocks,ramchain->height,width,tablesize,(double)(ramchain->sparseadditers + ramchain->sparsesearchiters)/(1+ramchain->sparsesearches+ramchain->sparseadds),ramchain->sparseadds,ramchain->sparseadditers,ramchain->sparsehits,ramchain->sparsesearches,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1);
if ( width == 32 ) if ( width == 32 )
{ {
table = (uint32_t *)bits; table = (uint32_t *)bits;
@ -197,11 +199,13 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
ind = 0; ind = 0;
if ( (x= table[ind]) == 0 ) if ( (x= table[ind]) == 0 )
{ {
if ( (retval= setind) != 0 )
table[ind] = setind;
if ( ++i > ramchain->sparsemax ) if ( ++i > ramchain->sparsemax )
ramchain->sparsemax = i; ramchain->sparsemax = i;
ramchain->sparseiters += i; if ( (retval= setind) != 0 )
{
ramchain->sparseadditers += i;
table[ind] = setind;
} else ramchain->sparsesearchiters += i;
return(setind); return(setind);
} }
else if ( memcmp((void *)(long)((long)refdata + x*refsize),key,keylen) == 0 ) else if ( memcmp((void *)(long)((long)refdata + x*refsize),key,keylen) == 0 )
@ -211,7 +215,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
ramchain->sparsehits++; ramchain->sparsehits++;
if ( ++i > ramchain->sparsemax ) if ( ++i > ramchain->sparsemax )
ramchain->sparsemax = i; ramchain->sparsemax = i;
ramchain->sparseiters += i; ramchain->sparseadditers += i;
return(x); return(x);
} }
} }
@ -223,7 +227,6 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset); printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset);
for (i=0; i<tablesize; i++,ind++,bitoffset+=width) for (i=0; i<tablesize; i++,ind++,bitoffset+=width)
{ {
ramchain->sparseiters++;
if ( ind >= tablesize ) if ( ind >= tablesize )
{ {
ind = 0; ind = 0;
@ -254,7 +257,11 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
if ( x == 0 ) if ( x == 0 )
{ {
if ( (x= setind) == 0 ) if ( (x= setind) == 0 )
{
ramchain->sparsesearchiters += (i+1);
return(0); return(0);
}
else ramchain->sparseadditers += (i+1);
if ( width == 32 ) if ( width == 32 )
memcpy(&bits[bitoffset >> 3],&setind,4); memcpy(&bits[bitoffset >> 3],&setind,4);
else if ( width == 16 ) else if ( width == 16 )

Loading…
Cancel
Save