|
|
@ -368,7 +368,7 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st |
|
|
|
*heightp = bp->bundleheight + j; |
|
|
|
//printf("found height.%d\n",*heightp);
|
|
|
|
*tx = T[txidind]; |
|
|
|
if ( k != 0 ) |
|
|
|
if ( k > 1 ) |
|
|
|
{ |
|
|
|
/*i = 0;
|
|
|
|
j = 1; |
|
|
@ -381,8 +381,8 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st |
|
|
|
i += j++; |
|
|
|
} |
|
|
|
permutation[k] = pendingval;*/ |
|
|
|
tmp = permutation[k-1]; |
|
|
|
permutation[k-1] = permutation[k]; |
|
|
|
tmp = permutation[k-2]; |
|
|
|
permutation[k-2] = permutation[k]; |
|
|
|
permutation[k] = tmp; |
|
|
|
} |
|
|
|
return(tx); |
|
|
@ -425,7 +425,7 @@ int32_t iguana_ramchain_spendtxid(struct iguana_info *coin,uint32_t *unspentindp |
|
|
|
return(-2); |
|
|
|
} |
|
|
|
|
|
|
|
struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spend_hdrsi,struct iguana_spend *s) |
|
|
|
struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spend_hdrsi,struct iguana_spend *s,int16_t *permutation) |
|
|
|
{ |
|
|
|
int32_t prev_vout,height,hdrsi; uint32_t sequenceid,unspentind; char str[65]; |
|
|
|
struct iguana_bundle *spentbp=0; struct iguana_txid *T,TX,*tp; bits256 *X; bits256 prev_hash; |
|
|
@ -450,7 +450,7 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre |
|
|
|
*unspentindp = unspentind; |
|
|
|
if ( unspentind == 0 ) |
|
|
|
{ |
|
|
|
if ( (tp= iguana_txidfind(coin,&height,&TX,prev_hash,ramchain->permutation,spend_hdrsi)) != 0 ) |
|
|
|
if ( (tp= iguana_txidfind(coin,&height,&TX,prev_hash,permutation,spend_hdrsi)) != 0 ) |
|
|
|
{ |
|
|
|
*unspentindp = unspentind = TX.firstvout + ((prev_vout > 0) ? prev_vout : 0); |
|
|
|
hdrsi = height / coin->chain->bundlesize; |
|
|
@ -659,7 +659,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
int32_t spendind,n,txidind,errs=0,emit=0,i,j,k,retval = -1; long fsize; |
|
|
|
uint32_t spent_unspentind,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata; |
|
|
|
struct iguana_bundle *spentbp; struct iguana_blockRO *B; FILE *fp; char fname[1024],str[65]; |
|
|
|
bits256 prevhash,zero,sha256; struct iguana_unspent *u,*spentU; struct iguana_txid *T; |
|
|
|
bits256 prevhash,zero,sha256; struct iguana_unspent *u,*spentU; struct iguana_txid *T; int16_t *permutation; |
|
|
|
struct iguana_spend *S,*s; struct iguana_spendvector *ptr; struct iguana_ramchain *ramchain; |
|
|
|
ramchain = &bp->ramchain; |
|
|
|
printf("iguana_spendvectors.[%d] gen.%d ramchain data.%p\n",bp->hdrsi,bp->bundleheight,ramchain->H.data); |
|
|
@ -678,6 +678,9 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
total += n; |
|
|
|
//printf("start UTXOGEN.%d max.%d ptr.%p\n",bp->bundleheight,n,ptr);
|
|
|
|
txidind = spendind = rdata->firsti; |
|
|
|
permutation = calloc(sizeof(*permutation),bp->hdrsi); |
|
|
|
for (i=0; i<bp->hdrsi; i++) |
|
|
|
permutation[i] = (bp->hdrsi - 1 - i); |
|
|
|
iguana_ramchain_prefetch(coin,ramchain); |
|
|
|
for (i=0; i<bp->n; i++) |
|
|
|
{ |
|
|
@ -685,6 +688,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
{ |
|
|
|
printf("utxogen: txidind %u != %u B[%d].firsttxidind || spendind %u != %u B[%d].firstvin\n",txidind,B[i].firsttxidind,i,spendind,B[i].firstvin,i); |
|
|
|
myfree(ptr,sizeof(*ptr) * n); |
|
|
|
free(permutation); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
for (j=0; j<B[i].txn_count && errs==0; j++,txidind++) |
|
|
@ -694,6 +698,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
{ |
|
|
|
printf("utxogen: txidind %u != %u nextT[txidind].firsttxidind || spendind %u != %u nextT[txidind].firstvin\n",txidind,T[txidind].txidind,spendind,T[txidind].firstvin); |
|
|
|
myfree(ptr,sizeof(*ptr) * n); |
|
|
|
free(permutation); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
for (k=0; k<T[txidind].numvins && errs==0; k++,spendind++) |
|
|
@ -702,7 +707,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
u = 0; |
|
|
|
if ( s->external != 0 && s->prevout >= 0 ) |
|
|
|
{ |
|
|
|
if ( (spentbp= iguana_externalspent(coin,&prevhash,&spent_unspentind,ramchain,bp->hdrsi,s)) != 0 && spentbp->ramchain.H.data != 0 ) |
|
|
|
if ( (spentbp= iguana_externalspent(coin,&prevhash,&spent_unspentind,ramchain,bp->hdrsi,s,permutation)) != 0 && spentbp->ramchain.H.data != 0 ) |
|
|
|
{ |
|
|
|
if ( spentbp == bp ) |
|
|
|
{ |
|
|
@ -785,6 +790,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
} |
|
|
|
if ( ptr != 0 ) |
|
|
|
myfree(ptr,sizeof(*ptr) * n); |
|
|
|
free(permutation); |
|
|
|
printf("duration.%d spendvectors %d spendinds.[%d] errs.%d [%.2f%%] emitted.%d %s of %d\n",(uint32_t)time(NULL)-starttime,spendind,bp->hdrsi,errs,100.*(double)emitted/(total+1),emit,mbstr(str,sizeof(*ptr) * emit),n); |
|
|
|
if ( errs != 0 ) |
|
|
|
exit(-1); |
|
|
@ -941,7 +947,7 @@ int32_t iguana_RTutxo(struct iguana_info *coin,struct iguana_bundle *bp,struct i |
|
|
|
s = &S[spendind]; |
|
|
|
if ( s->external != 0 && s->prevout >= 0 ) |
|
|
|
{ |
|
|
|
if ( (spentbp= iguana_externalspent(coin,&prevhash,&spent_unspentind,RTramchain,bp->hdrsi,s)) == 0 || spent_unspentind == 0 || spent_unspentind >= spentbp->ramchain.H.data->numunspents || spentbp->hdrsi < 0 || spentbp->hdrsi >= bp->hdrsi || spentbp == bp ) |
|
|
|
if ( (spentbp= iguana_externalspent(coin,&prevhash,&spent_unspentind,RTramchain,bp->hdrsi,s,0)) == 0 || spent_unspentind == 0 || spent_unspentind >= spentbp->ramchain.H.data->numunspents || spentbp->hdrsi < 0 || spentbp->hdrsi >= bp->hdrsi || spentbp == bp ) |
|
|
|
{ |
|
|
|
char str[65]; |
|
|
|
printf("RTutxo: unexpected spendbp: height.%d bp.[%d] U%d <- S%d.[%d] [ext.%d %s prev.%d]\n",height,spentbp->hdrsi,spent_unspentind,spendind,bp->hdrsi,s->external,bits256_str(str,prevhash),s->prevout); |
|
|
|