Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
39c99e94d0
  1. 44
      iguana/iguana_ramchain.c
  2. 26
      iguana/iguana_unspents.c
  3. 4
      iguana/main.c

44
iguana/iguana_ramchain.c

@ -805,6 +805,46 @@ void *iguana_ramchain_offset(void *dest,uint8_t *lhash,FILE *fp,uint64_t fpos,vo
return((void *)(long)((long)destptr + fpos));
}
void iguana_ramchain_prefetch(struct iguana_info *coin,struct iguana_ramchain *ramchain)
{
struct iguana_pkhash *P,p; struct iguana_unspent *U,u; struct iguana_txid *T,txid; uint32_t i,numpkinds,numtxids,numunspents,tlen,plen,nonz=0; uint8_t *PKbits,*TXbits,*ptr;
if ( ramchain->H.data != 0 )
{
ptr = ramchain->fileptr;
for (i=0; i<ramchain->filesize; i++)
if ( ptr[i] != 0 )
nonz++;
printf("nonz.%d of %d\n",nonz,(int32_t)ramchain->filesize);
return;
U = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Uoffset);
T = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Toffset);
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset);
TXbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->TXoffset);
PKbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->PKoffset);
numpkinds = ramchain->H.data->numpkinds;
numunspents = ramchain->H.data->numunspents;
numtxids = ramchain->H.data->numtxids;
tlen = ramchain->H.data->numtxsparse * ramchain->H.data->txsparsebits;
plen = ramchain->H.data->numpksparse * ramchain->H.data->pksparsebits;
if ( 0 )
{
for (i=1; i<numtxids; i++)
memcpy(&txid,&T[i],sizeof(txid));
for (i=1; i<numunspents; i++)
memcpy(&u,&U[i],sizeof(u));
for (i=1; i<numpkinds; i++)
memcpy(&p,&P[i],sizeof(p));
}
for (i=0; i<tlen; i++)
if ( TXbits[i] != 0 )
nonz++;
for (i=0; i<plen; i++)
if ( PKbits[i] != 0 )
nonz++;
printf("nonz.%d\n",nonz);
}
}
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)
@ -1449,7 +1489,7 @@ struct iguana_ramchain *iguana_ramchain_map(struct iguana_info *coin,char *fname
ramchain->H.ROflag = 1;
ramchain->expanded = expanded;
ramchain->numblocks = (bp == 0) ? 1 : bp->n;
printf("ptr.%p %p mapped P[%d] fpos.%d + %ld -> %ld vs %ld offset.%u:%u stack.%u:%u\n",ptr,ramchain->H.data,(int32_t)ramchain->H.data->Poffset,(int32_t)fpos,(long)ramchain->H.data->allocsize,(long)(fpos + ramchain->H.data->allocsize),ramchain->filesize,ramchain->H.scriptoffset,ramchain->H.data->scriptspace,ramchain->H.stacksize,ramchain->H.data->stackspace);
printf("ptr.%p exp.%d extra.%d %p mapped P[%d] fpos.%d + %ld -> %ld vs %ld offset.%u:%u stack.%u:%u\n",ptr,expanded,allocextras,ramchain->H.data,(int32_t)ramchain->H.data->Poffset,(int32_t)fpos,(long)ramchain->H.data->allocsize,(long)(fpos + ramchain->H.data->allocsize),ramchain->filesize,ramchain->H.scriptoffset,ramchain->H.data->scriptspace,ramchain->H.stacksize,ramchain->H.data->stackspace);
if ( 0 && bp != 0 )
{
/*blocksRO = (struct iguana_blockRO *)ramchain->H.data;
@ -1504,7 +1544,7 @@ struct iguana_ramchain *iguana_ramchain_map(struct iguana_info *coin,char *fname
{
bp->balancefinish = (uint32_t)time(NULL);
printf("found balances for %d\n",bp->hdrsi);
}
} else printf("error with extras\n");
}
}
if ( B != 0 && bp != 0 )

26
iguana/iguana_unspents.c

@ -224,26 +224,6 @@ int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf
return(n);
}
void iguana_ramchain_prefetch(struct iguana_info *coin,struct iguana_ramchain *ramchain)
{
struct iguana_pkhash *P,p; struct iguana_unspent *U,u; struct iguana_txid *T,txid; uint32_t i,numpkinds,numtxids,numunspents;
if ( ramchain->H.data != 0 )
{
U = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Uoffset);
T = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Toffset);
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset);
numpkinds = ramchain->H.data->numpkinds;
numunspents = ramchain->H.data->numunspents;
numtxids = ramchain->H.data->numtxids;
for (i=1; i<numtxids; i++)
memcpy(&txid,&T[i],sizeof(txid));
for (i=1; i<numunspents; i++)
memcpy(&u,&U[i],sizeof(u));
for (i=1; i<numpkinds; i++)
memcpy(&p,&P[i],sizeof(p));
}
}
void iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds)
{
int64_t total,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,flag = 0; char coinaddr[64];
@ -470,7 +450,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3
now = (uint32_t)time(NULL);
if ( spentbp != 0 && unspentind > 0 && unspentind < spentbp->ramchain.H.data->numunspents )
{
if ( spentbp->dirty++ == 100 )
if ( spentbp->dirty++ == 3 )
{
printf("prefetch.[%d]\n",spentbp->hdrsi);
iguana_ramchain_prefetch(coin,&spentbp->ramchain);
@ -479,12 +459,12 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3
{
if ( spentbp->ramchain.Uextras == 0 )
{
//printf("alloc Uextras.[%d]\n",spentbp->hdrsi);
printf("unspent alloc Uextras.[%d]\n",spentbp->hdrsi);
spentbp->ramchain.Uextras = calloc(sizeof(*spentbp->ramchain.Uextras),spentbp->ramchain.H.data->numunspents + 16);
}
if ( spentbp->ramchain.A == 0 )
{
//printf("alloc A2.[%d]\n",spentbp->hdrsi);
printf("unspent alloc A2.[%d]\n",spentbp->hdrsi);
spentbp->ramchain.A = calloc(sizeof(*spentbp->ramchain.A),spentbp->ramchain.H.data->numpkinds + 16);
}
}

4
iguana/main.c

@ -329,7 +329,9 @@ void sigcontinue_func() { printf("\nSIGCONT\n"); signal(SIGCONT,sigcontinue_func
// mksquashfs DB/BTC BTC.xz1m -b 1048576 -comp xz -Xdict-size 1024K -> takes a long time ->
/*
mksquashfs DB/BTC BTC.xz -comp xz
mksquashfs DB/BTC BTC.xz1m -b 1048576 -comp xz -Xdict-size 1024K
mksquashfs DB/BTC BTC.xzs -b 16384 -comp xz -Xdict-size 8K
mksquashfs DB/BTC BTC.xz1m -b 1048576 -comp xz -Xdict-size 1024K
mksquashfs DB/BTC BTC.xz8k -comp xz -Xdict-size 8K
mksquashfs DB/BTC BTC.lzo -comp lzo
mksquashfs DB/BTC BTC.lzo1m -comp lzo -b 1048576
mksquashfs DB/BTC BTC.squash

Loading…
Cancel
Save