diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 08b6f583a..1717e3aaa 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -18,7 +18,7 @@ #include "../crypto777/OS_portable.h" #include "SuperNET.h" -#define SPARSECOUNT(x) ((x) << 1) +#define SPARSECOUNT(x) ((x) << 2) typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t len); @@ -336,7 +336,7 @@ struct iguana_unspent20 { uint64_t value; uint32_t scriptpos,txidind:28,type:4; struct iguana_spend256 { bits256 prevhash2; uint32_t sequenceid,scriptpos; int16_t prevout; uint16_t vinscriptlen,spendind,fileid; } __attribute__((packed)); // permanent readonly structs -struct iguana_txid { bits256 txid; uint32_t txidind,firstvout,firstvin,locktime,version,timestamp,extraoffset; uint16_t numvouts,numvins; } __attribute__((packed)); +struct iguana_txid { bits256 txid; uint32_t txidind:29,firstvout:28,firstvin:28,bundlei:11,locktime,version,timestamp,extraoffset; uint16_t numvouts,numvins; } __attribute__((packed)); struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos; uint16_t scriptlen,hdrsi; uint16_t fileid:11,type:5; int16_t vout; } __attribute__((packed)); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 7d9e06190..f667bd4da 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -156,6 +156,8 @@ int32_t iguana_peerfile_exists(struct iguana_info *coin,struct iguana_peer *addr uint32_t iguana_ramchain_addtxid(struct iguana_info *coin,RAMCHAIN_FUNC,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp,int16_t bundlei) { uint32_t txidind; struct iguana_txid *t; struct iguana_kvitem *ptr; + if ( sizeof(*t) != 64 ) + printf("sizeof iguana_txid.%ld != 64?\n",sizeof(*t)); txidind = ramchain->H.txidind; t = &T[txidind]; if ( ramchain->H.ROflag != 0 ) @@ -172,8 +174,14 @@ uint32_t iguana_ramchain_addtxid(struct iguana_info *coin,RAMCHAIN_FUNC,bits256 if ( 0 && ramchain->expanded != 0 ) printf("T.%p txidind.%d numvouts.%d numvins.%d\n",T,txidind,numvouts,numvins); t->txidind = txidind, t->txid = txid, t->numvouts = numvouts, t->numvins = numvins; + t->bundlei = bundlei; t->firstvout = ramchain->H.unspentind, t->firstvin = ramchain->H.spendind; t->locktime = locktime, t->version = version, t->timestamp = timestamp; + if ( t->txidind != txidind || t->firstvout != ramchain->H.unspentind || t->firstvin != ramchain->H.spendind || t->bundlei != bundlei ) + { + printf("addtxid error: t->txidind %u != %u txidind || t->firstvout %u != %u ramchain->H.unspentind || t->firstvin %u != %u ramchain->H.spendind || t->bundlei %u != %u bundlei\n",t->txidind,txidind,t->firstvout,ramchain->H.unspentind,t->firstvin,ramchain->H.spendind,t->bundlei,bundlei); + return(0); + } if ( ramchain->expanded != 0 ) iguana_sparseaddtx(TXbits,ramchain->H.data->txsparsebits,ramchain->H.data->numtxsparse,txid,T,txidind,ramchain); //if ( txidind <= 2 ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index e903b4678..f3544df31 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -388,15 +388,21 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st //printf("found txidind.%d\n",txidind); if ( bits256_cmp(txid,T[txidind].txid) == 0 ) { - /*for (j=0; jn; j++) + int32_t j; struct iguana_block *block; + for (j=0; jn; j++) if ( (block= bp->blocks[j]) != 0 && txidind >= block->RO.firsttxidind && txidind < block->RO.firsttxidind+block->RO.txn_count ) break; - if ( j < bp->n )*/ + if ( j < bp->n ) { - *heightp = bp->bundleheight + T[txidind].extraoffset;//bundlei; - //printf("found height.%d\n",*heightp); - *tx = T[txidind]; - return(tx); + if ( j != T[txidind].bundlei ) + printf("bundlei mismatch j.%d != %d\n",j,T[txidind].bundlei); + else + { + *heightp = bp->bundleheight + T[txidind].bundlei; + //printf("found height.%d\n",*heightp); + *tx = T[txidind]; + return(tx); + } } /*for (j=0; jn; j++) if ( (block= bp->blocks[j]) != 0 ) @@ -939,7 +945,7 @@ int32_t iguana_RTutxo(struct iguana_info *coin,struct iguana_bundle *bp,struct i spendind = B[bundlei].firstvin; height = bp->bundleheight + bundlei; now = (uint32_t)time(NULL); - printf("RTutxo.[%d:%d] txn_count.%d\n",bp->hdrsi,bundlei,B[bundlei].txn_count); + //printf("RTutxo.[%d:%d] txn_count.%d\n",bp->hdrsi,bundlei,B[bundlei].txn_count); for (j=0; jRTheight++; printf(">>>> RT.%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",coin->RTheight,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,(long)dest->H.data->allocsize); coin->RTramchain.H.data->numblocks = bundlei + 1;