Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
9396a45868
  1. 4
      iguana/iguana777.h
  2. 8
      iguana/iguana_ramchain.c
  3. 16
      iguana/iguana_unspents.c

4
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) << 1) #define SPARSECOUNT(x) ((x) << 2)
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);
@ -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)); struct iguana_spend256 { bits256 prevhash2; uint32_t sequenceid,scriptpos; int16_t prevout; uint16_t vinscriptlen,spendind,fileid; } __attribute__((packed));
// permanent readonly structs // 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)); 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));

8
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 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; 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; txidind = ramchain->H.txidind;
t = &T[txidind]; t = &T[txidind];
if ( ramchain->H.ROflag != 0 ) 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 ) if ( 0 && ramchain->expanded != 0 )
printf("T.%p txidind.%d numvouts.%d numvins.%d\n",T,txidind,numvouts,numvins); 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->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->firstvout = ramchain->H.unspentind, t->firstvin = ramchain->H.spendind;
t->locktime = locktime, t->version = version, t->timestamp = timestamp; 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 ) if ( ramchain->expanded != 0 )
iguana_sparseaddtx(TXbits,ramchain->H.data->txsparsebits,ramchain->H.data->numtxsparse,txid,T,txidind,ramchain); iguana_sparseaddtx(TXbits,ramchain->H.data->txsparsebits,ramchain->H.data->numtxsparse,txid,T,txidind,ramchain);
//if ( txidind <= 2 ) //if ( txidind <= 2 )

16
iguana/iguana_unspents.c

@ -388,16 +388,22 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st
//printf("found txidind.%d\n",txidind); //printf("found txidind.%d\n",txidind);
if ( bits256_cmp(txid,T[txidind].txid) == 0 ) if ( bits256_cmp(txid,T[txidind].txid) == 0 )
{ {
/*for (j=0; j<bp->n; j++) int32_t j; struct iguana_block *block;
for (j=0; j<bp->n; j++)
if ( (block= bp->blocks[j]) != 0 && txidind >= block->RO.firsttxidind && txidind < block->RO.firsttxidind+block->RO.txn_count ) if ( (block= bp->blocks[j]) != 0 && txidind >= block->RO.firsttxidind && txidind < block->RO.firsttxidind+block->RO.txn_count )
break; break;
if ( j < bp->n )*/ if ( j < bp->n )
{
if ( j != T[txidind].bundlei )
printf("bundlei mismatch j.%d != %d\n",j,T[txidind].bundlei);
else
{ {
*heightp = bp->bundleheight + T[txidind].extraoffset;//bundlei; *heightp = bp->bundleheight + T[txidind].bundlei;
//printf("found height.%d\n",*heightp); //printf("found height.%d\n",*heightp);
*tx = T[txidind]; *tx = T[txidind];
return(tx); return(tx);
} }
}
/*for (j=0; j<bp->n; j++) /*for (j=0; j<bp->n; j++)
if ( (block= bp->blocks[j]) != 0 ) if ( (block= bp->blocks[j]) != 0 )
printf("(%d %d).%d ",block->RO.firsttxidind,block->RO.txn_count,txidind >= block->RO.firsttxidind && txidind < block->RO.firsttxidind+block->RO.txn_count); printf("(%d %d).%d ",block->RO.firsttxidind,block->RO.txn_count,txidind >= block->RO.firsttxidind && txidind < block->RO.firsttxidind+block->RO.txn_count);
@ -939,7 +945,7 @@ int32_t iguana_RTutxo(struct iguana_info *coin,struct iguana_bundle *bp,struct i
spendind = B[bundlei].firstvin; spendind = B[bundlei].firstvin;
height = bp->bundleheight + bundlei; height = bp->bundleheight + bundlei;
now = (uint32_t)time(NULL); 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; j<B[bundlei].txn_count; j++,txidind++) for (j=0; j<B[bundlei].txn_count; j++,txidind++)
{ {
if ( txidind != T[txidind].txidind || spendind != T[txidind].firstvin ) if ( txidind != T[txidind].txidind || spendind != T[txidind].firstvin )
@ -1294,7 +1300,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
} }
totalmillis += (OS_milliseconds() - startmillis); totalmillis += (OS_milliseconds() - startmillis);
num++; num++;
printf("RTutxo.[%d] ave %.2f micros, total %.2f seconds\n",num,(totalmillis*1000.)/num,totalmillis/1000.); //printf("RTutxo.[%d] ave %.2f micros, total %.2f seconds\n",num,(totalmillis*1000.)/num,totalmillis/1000.);
coin->RTheight++; coin->RTheight++;
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); 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; coin->RTramchain.H.data->numblocks = bundlei + 1;

Loading…
Cancel
Save