Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
4bbfa7cb03
  1. 2
      iguana/iguana777.h
  2. 11
      iguana/iguana_ramchain.c
  3. 27
      iguana/iguana_unspents.c

2
iguana/iguana777.h

@ -389,7 +389,7 @@ struct iguana_ramchain
void *fileptr,*sigsfileptr,*Xspendptr,*debitsfileptr,*lastspendsfileptr;
char from_ro,from_roX,from_roA,from_roU;
struct iguana_account *A,*creditsA; struct iguana_spendvector *Xspendinds;
struct iguana_utxo *Uextras; uint8_t *txbits;
struct iguana_utxo *Uextras; uint8_t *txbits; struct iguana_txid *cacheT;
//int16_t permutation[IGUANA_MAXBUNDLES];
//struct iguana_Uextra *U2,*roU2; struct iguana_pkextra *P2,*roP2;
};

11
iguana/iguana_ramchain.c

@ -678,6 +678,7 @@ int32_t iguana_ramchain_prefetch(struct iguana_info *coin,struct iguana_ramchain
{
RAMCHAIN_DECLARE; RAMCHAIN_ZEROES;
struct iguana_pkhash p; struct iguana_unspent u; struct iguana_txid txid; uint32_t i,numpkinds,numtxids,numunspents,numexternal,tlen,plen,nonz=0; uint8_t *ptr;
return(0);
if ( ramchain->H.data != 0 )
{
if ( flag == 0 )
@ -1238,6 +1239,16 @@ int32_t iguana_ramchain_free(struct iguana_info *coin,struct iguana_ramchain *ra
myfree(item,sizeof(*item));
}
}
if ( ramchain->txbits != 0 )
{
free(ramchain->txbits);
ramchain->txbits = 0;
}
if ( ramchain->cacheT != 0 )
{
free(ramchain->cacheT);
ramchain->cacheT = 0;
}
}
ramchain->txids = 0;
ramchain->pkhashes = 0;

27
iguana/iguana_unspents.c

@ -131,6 +131,23 @@ int32_t iguana_alloctxbits(struct iguana_info *coin,struct iguana_ramchain *ramc
return(-1);
}
int32_t iguana_alloccacheT(struct iguana_info *coin,struct iguana_ramchain *ramchain)
{
static int64_t total;
if ( ramchain->cacheT == 0 )
{
int32_t tlen; struct iguana_txid *T = (void *)((long)ramchain->H.data + ramchain->H.data->Toffset);
tlen = sizeof(*T) * ramchain->H.data->numtxids;
ramchain->cacheT = calloc(1,tlen);
memcpy(ramchain->cacheT,T,tlen);
total += tlen;
//char str[65]; printf("alloc.[%d] txbits.%p[%d] total %s\n",ramchain->H.data->height/coin->chain->bundlesize,ramchain->cacheT,tlen,mbstr(str,total));
return(tlen);
}
return(-1);
}
void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramchain)
{
if ( ramchain != 0 && ramchain->H.data != 0 )
@ -561,7 +578,13 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st
TXbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->TXoffset);
}
}
T = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Toffset);
if ( (T= ramchain->cacheT) == 0 )
{
if ( coin->PREFETCHLAG >= 0 )
iguana_alloccacheT(coin,ramchain);
if ( (T= ramchain->cacheT) == 0 )
T = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Toffset);
}
if ( (txidind= iguana_sparseaddtx(TXbits,ramchain->H.data->txsparsebits,ramchain->H.data->numtxsparse,txid,T,0,ramchain)) > 0 )
{
//printf("found txidind.%d\n",txidind);
@ -2030,7 +2053,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,
fclose(fp);
}
}
} else printf("skip validate.[%d] validated.%u force.%d\n",bp->hdrsi,bp->validated,forceflag);
} // else printf("skip validate.[%d] validated.%u force.%d\n",bp->hdrsi,bp->validated,forceflag);
if ( errs != 0 )
{
printf("remove.[%d]\n",bp->hdrsi);

Loading…
Cancel
Save