Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
1ef3dfd3f3
  1. 2
      iguana/iguana777.h
  2. 14
      iguana/iguana_ramchain.c
  3. 53
      iguana/iguana_unspents.c

2
iguana/iguana777.h

@ -18,7 +18,7 @@
#include "../crypto777/OS_portable.h" #include "../crypto777/OS_portable.h"
#include "SuperNET.h" #include "SuperNET.h"
#define SPARSECOUNT(x) ((x) << 2) #define SPARSECOUNT(x) ((3*(x)) >> 1)
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);

14
iguana/iguana_ramchain.c

@ -691,18 +691,30 @@ void iguana_ramchain_prefetch(struct iguana_info *coin,struct iguana_ramchain *r
int64_t _iguana_rdata_action(FILE *fp,bits256 lhashes[IGUANA_NUMLHASHES],void *destptr,uint64_t fpos,uint32_t expanded,uint32_t numtxids,uint32_t numunspents,uint32_t numspends,uint32_t numpkinds,uint32_t numexternaltxids,uint32_t scriptspace,uint32_t txsparsebits,uint64_t numtxsparse,uint32_t pksparsebits,uint64_t numpksparse,uint64_t srcsize,RAMCHAIN_FUNC,int32_t numblocks) int64_t _iguana_rdata_action(FILE *fp,bits256 lhashes[IGUANA_NUMLHASHES],void *destptr,uint64_t fpos,uint32_t expanded,uint32_t numtxids,uint32_t numunspents,uint32_t numspends,uint32_t numpkinds,uint32_t numexternaltxids,uint32_t scriptspace,uint32_t txsparsebits,uint64_t numtxsparse,uint32_t pksparsebits,uint64_t numpksparse,uint64_t srcsize,RAMCHAIN_FUNC,int32_t numblocks)
{ {
#define RAMCHAIN_LARG(ind) ((lhashes == 0) ? 0 : lhashes[ind].bytes) #define RAMCHAIN_LARG(ind) ((lhashes == 0) ? 0 : lhashes[ind].bytes)
#define SPARSECOUNT(x) ((x) << 2) #define SPARSECOUNT(x) ((3*(x)) >> 1)
FILE *fparg = 0; int32_t iter; uint64_t txbits,pkbits,offset = 0; struct iguana_ramchaindata *rdata = destptr; FILE *fparg = 0; int32_t iter; uint64_t txbits,pkbits,offset = 0; struct iguana_ramchaindata *rdata = destptr;
if ( expanded != 0 ) if ( expanded != 0 )
{ {
if( txsparsebits == 0 || numtxsparse == 0 ) if( txsparsebits == 0 || numtxsparse == 0 )
{ {
txsparsebits = hcalc_bitsize(numtxids); txsparsebits = hcalc_bitsize(numtxids);
if ( txsparsebits < 8 )
txsparsebits = 8;
else if ( txsparsebits < 16 )
txsparsebits = 16;
else if ( txsparsebits < 32 )
txsparsebits = 32;
numtxsparse = SPARSECOUNT(numtxids); numtxsparse = SPARSECOUNT(numtxids);
} }
if ( pksparsebits == 0 || numpksparse == 0 ) if ( pksparsebits == 0 || numpksparse == 0 )
{ {
pksparsebits = hcalc_bitsize(numpkinds); pksparsebits = hcalc_bitsize(numpkinds);
if ( pksparsebits < 8 )
pksparsebits = 8;
else if ( pksparsebits < 16 )
pksparsebits = 16;
else if ( pksparsebits < 32 )
pksparsebits = 32;
numpksparse = SPARSECOUNT(numpkinds); numpksparse = SPARSECOUNT(numpkinds);
} }
txbits = numtxsparse * txsparsebits; pkbits = numpksparse * pksparsebits; txbits = numtxsparse * txsparsebits; pkbits = numpksparse * pksparsebits;

53
iguana/iguana_unspents.c

@ -190,7 +190,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
if ( 0 && setind == 0 ) if ( 0 && setind == 0 )
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);
if ( (ramchain->sparsesearches % 100000) == 0 ) if ( (ramchain->sparsesearches % 100000) == 0 )
printf("[%d %d] %.3f sparse searches.%ld iters.%ld hits.%ld %.2f%% max.%ld\n",width,tablesize,(double)ramchain->sparseiters/(1+ramchain->sparsesearches),ramchain->sparsesearches,ramchain->sparseiters,ramchain->sparsehits,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1); printf("%7d.[%-2d %8d] %5.3f sparse searches.%-8ld iters.%-8ld hits.%-8ld %5.2f%% max.%ld\n",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);
for (i=0; i<tablesize; i++,ind++,bitoffset+=width) for (i=0; i<tablesize; i++,ind++,bitoffset+=width)
{ {
ramchain->sparseiters++; ramchain->sparseiters++;
@ -199,33 +199,50 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
ind = 0; ind = 0;
bitoffset = 0; bitoffset = 0;
} }
ptr = &bits[bitoffset >> 3]; x = 0;
modval = (bitoffset & 7); if ( width == 32 )
if ( 0 && setind == 0 ) memcpy(&x,&bits[bitoffset >> 5],4);
printf("tablesize.%d width.%d bitoffset.%d modval.%d i.%d\n",tablesize,width,(int32_t)bitoffset,modval,i); else if ( width == 16 )
for (x=j=0; j<width; j++,modval++) memcpy(&x,&bits[bitoffset >> 4],2);
else if ( width != 8 )
{ {
if ( modval >= 8 ) ptr = &bits[bitoffset >> 3];
ptr++, modval = 0; modval = (bitoffset & 7);
x <<= 1; if ( 0 && setind == 0 )
x |= (*ptr & masks[modval]) >> modval; printf("tablesize.%d width.%d bitoffset.%d modval.%d i.%d\n",tablesize,width,(int32_t)bitoffset,modval,i);
for (x=j=0; j<width; j++,modval++)
{
if ( modval >= 8 )
ptr++, modval = 0;
x <<= 1;
x |= (*ptr & masks[modval]) >> modval;
}
} }
else x = bits[bitoffset >> 3];
if ( 0 && setind == 0 ) if ( 0 && setind == 0 )
printf("x.%d\n",x); printf("x.%d\n",x);
if ( x == 0 ) if ( x == 0 )
{ {
if ( (x= setind) == 0 ) if ( (x= setind) == 0 )
return(0); return(0);
ptr = &bits[(bitoffset+width-1) >> 3]; if ( width == 32 )
modval = ((bitoffset+width-1) & 7); memcpy(&bits[bitoffset >> 5],&x,4);
for (j=0; j<width; j++,x>>=1,modval--) else if ( width == 16 )
memcpy(&bits[bitoffset >> 4],&x,2);
else if ( width != 8 )
{ {
if ( modval < 0 ) ptr = &bits[(bitoffset+width-1) >> 3];
ptr--, modval = 7; modval = ((bitoffset+width-1) & 7);
if ( (x & 1) != 0 ) for (j=0; j<width; j++,x>>=1,modval--)
*ptr |= masks[modval]; {
if ( modval < 0 )
ptr--, modval = 7;
if ( (x & 1) != 0 )
*ptr |= masks[modval];
}
} }
if ( 0 ) else bits[bitoffset >> 3] = x;
if ( 1 )
{ {
for (x=j=0; j<width; j++) for (x=j=0; j<width; j++)
{ {

Loading…
Cancel
Save