Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
ef06f75a48
  1. 5
      iguana/iguana_blocks.c
  2. 3
      iguana/iguana_ramchain.c
  3. 14
      iguana/iguana_realtime.c
  4. 11
      iguana/iguana_recv.c
  5. 2
      includes/iguana_structs.h

5
iguana/iguana_blocks.c

@ -79,10 +79,15 @@ void iguana_blockcopy(uint8_t zcash,uint8_t auxpow,struct iguana_info *coin,stru
block->RO.timestamp = origblock->RO.timestamp; block->RO.timestamp = origblock->RO.timestamp;
if ( block->RO.bits == 0 ) if ( block->RO.bits == 0 )
block->RO.bits = origblock->RO.bits; block->RO.bits = origblock->RO.bits;
portable_mutex_lock(&coin->RTmutex);
if ( block->serialized == 0 ) if ( block->serialized == 0 )
{
block->serialized = origblock->serialized; block->serialized = origblock->serialized;
block->datalen = origblock->datalen;
}
if ( block->RO.txn_count == 0 ) if ( block->RO.txn_count == 0 )
block->RO.txn_count = origblock->RO.txn_count; block->RO.txn_count = origblock->RO.txn_count;
portable_mutex_lock(&coin->RTmutex);
if ( block->RO.version == 0 ) if ( block->RO.version == 0 )
block->RO.version = origblock->RO.version; block->RO.version = origblock->RO.version;
if ( block->mainchain == 0 ) if ( block->mainchain == 0 )

3
iguana/iguana_ramchain.c

@ -2766,7 +2766,7 @@ void iguana_ramchainmerge(struct iguana_info *coin) // jl777: verify prev/next h
int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDATA,struct OS_memspace *HASHMEM,int64_t polarity,struct iguana_block *block,struct iguana_msgtx *txarray,int32_t txn_count) int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDATA,struct OS_memspace *HASHMEM,int64_t polarity,struct iguana_block *block,struct iguana_msgtx *txarray,int32_t txn_count)
{ {
RAMCHAIN_DECLARE; struct vin_info V; struct iguana_ramchain R,*ramchain = &R; struct iguana_msgtx *tx; char fname[1024],str[65],coinaddr[64]; uint8_t *script; struct iguana_ramchaindata *rdata; int32_t hdrsi,bundlei,i,j,k,type,scriptlen,firsti = 1; RAMCHAIN_DECLARE; struct vin_info V; struct iguana_ramchain R,*ramchain = &R; struct iguana_msgtx *tx; char fname[1024],coinaddr[64]; uint8_t *script; struct iguana_ramchaindata *rdata; int32_t hdrsi,bundlei,i,j,k,type,scriptlen,firsti = 1;
if ( block->RO.txn_count != txn_count ) if ( block->RO.txn_count != txn_count )
{ {
printf("txn_count mismatch ht.%d %d != %d\n",block->height,block->RO.txn_count,txn_count); printf("txn_count mismatch ht.%d %d != %d\n",block->height,block->RO.txn_count,txn_count);
@ -2791,7 +2791,6 @@ int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDAT
for (i=0; i<txn_count; i++,ramchain->H.txidind++) for (i=0; i<txn_count; i++,ramchain->H.txidind++)
{ {
tx = &txarray[i]; tx = &txarray[i];
printf("txid.(%s) vouts.%d vins.%d\n",bits256_str(str,tx->txid),tx->tx_out,tx->tx_in);
iguana_RTtxid(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp); iguana_RTtxid(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp);
for (j=0; j<tx->tx_out; j++) for (j=0; j<tx->tx_out; j++)
{ {

14
iguana/iguana_realtime.c

@ -494,8 +494,8 @@ void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight)
void iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp) void iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp)
{ {
//char str[65]; char str[65];
//printf("txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",bits256_str(str,txid),numvouts,numvins,version,locktime,timestamp,(long long)polarity); printf("%s txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",coin->symbol,bits256_str(str,txid),numvouts,numvins,version,locktime,timestamp,(long long)polarity);
} }
void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout) void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout)
@ -516,6 +516,9 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_
void iguana_RTiterate(struct iguana_info *coin,struct iguana_block *block,int64_t polarity) void iguana_RTiterate(struct iguana_info *coin,struct iguana_block *block,int64_t polarity)
{ {
struct iguana_txblock txdata; int32_t n,len; struct iguana_txblock txdata; int32_t n,len;
if ( block->serialized == 0 )
printf("load from tmpdir ht.%d polarity.%lld\n",block->height,(long long)polarity);
portable_mutex_lock(&coin->RTmutex);
if ( block->serialized != 0 ) if ( block->serialized != 0 )
{ {
memset(&txdata,0,sizeof(txdata)); memset(&txdata,0,sizeof(txdata));
@ -526,11 +529,12 @@ void iguana_RTiterate(struct iguana_info *coin,struct iguana_block *block,int64_
if ( coin->RThashmem.ptr == 0 ) if ( coin->RThashmem.ptr == 0 )
iguana_meminit(&coin->RThashmem,"RThashmem",0,IGUANA_MAXPACKETSIZE * 2,0); iguana_meminit(&coin->RThashmem,"RThashmem",0,IGUANA_MAXPACKETSIZE * 2,0);
iguana_memreset(&coin->RTrawmem), iguana_memreset(&coin->RTmem), iguana_memreset(&coin->RThashmem); iguana_memreset(&coin->RTrawmem), iguana_memreset(&coin->RTmem), iguana_memreset(&coin->RThashmem);
if ( (n= iguana_gentxarray(coin,&coin->RTrawmem,&txdata,&len,block->serialized,block->RO.recvlen)) > 0 ) if ( (n= iguana_gentxarray(coin,&coin->RTrawmem,&txdata,&len,block->serialized,block->datalen)) > 0 )
{ {
iguana_RTramchaindata(coin,&coin->RTmem,&coin->RThashmem,polarity,block,coin->RTrawmem.ptr,block->RO.txn_count); iguana_RTramchaindata(coin,&coin->RTmem,&coin->RThashmem,polarity,block,coin->RTrawmem.ptr,block->RO.txn_count);
} else printf("gentxarray n.%d RO.txn_count.%d recvlen.%d\n",n,block->RO.txn_count,block->RO.recvlen); } else printf("gentxarray n.%d RO.txn_count.%d recvlen.%d\n",n,block->RO.txn_count,block->datalen);
} else printf("so serialized for ht.%d %p\n",block->height,block); } else printf("no serialized for ht.%d %p\n",block->height,block);
portable_mutex_unlock(&coin->RTmutex);
/* struct iguana_utxoaddr *utxoaddr; struct iguana_pkhash *P; struct iguana_txid *T,*t; struct iguana_unspent20 *u,*U; struct iguana_spend256 *S,*s; int32_t i,prevout,hdrsi,bundlei,spent_hdrsi; int64_t spent_value; uint32_t spendind,pkind,unspentind,txidind,spent_txidind,spent_pkind; uint8_t rmd160[20]; char fname[1024],str[65]; long filesize; int32_t err; void *ptr=0; struct iguana_ramchain R; struct iguana_ramchaindata *rdata; bits256 prevhash2; /* struct iguana_utxoaddr *utxoaddr; struct iguana_pkhash *P; struct iguana_txid *T,*t; struct iguana_unspent20 *u,*U; struct iguana_spend256 *S,*s; int32_t i,prevout,hdrsi,bundlei,spent_hdrsi; int64_t spent_value; uint32_t spendind,pkind,unspentind,txidind,spent_txidind,spent_pkind; uint8_t rmd160[20]; char fname[1024],str[65]; long filesize; int32_t err; void *ptr=0; struct iguana_ramchain R; struct iguana_ramchaindata *rdata; bits256 prevhash2;
memset(&R,0,sizeof(R)); memset(&R,0,sizeof(R));

11
iguana/iguana_recv.c

@ -500,7 +500,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
{ {
txdata->zblock.serialized = calloc(1,recvlen); txdata->zblock.serialized = calloc(1,recvlen);
memcpy(txdata->zblock.serialized,data,recvlen); memcpy(txdata->zblock.serialized,data,recvlen);
txdata->zblock.RO.recvlen = recvlen; txdata->zblock.datalen = recvlen;
} }
portable_mutex_unlock(&coin->RTmutex); portable_mutex_unlock(&coin->RTmutex);
req->zblock = txdata->zblock; req->zblock = txdata->zblock;
@ -1094,6 +1094,15 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
} }
if ( (bp= iguana_bundleset(coin,&block,&bundlei,(struct iguana_block *)origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 ) if ( (bp= iguana_bundleset(coin,&block,&bundlei,(struct iguana_block *)origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 )
{ {
portable_mutex_lock(&coin->RTmutex);
if ( block->serialized != 0 && origblock->serialized != 0 )
{
free(block->serialized);
block->serialized = origblock->serialized;
origblock->serialized = 0;
block->datalen = origblock->datalen;
}
portable_mutex_unlock(&coin->RTmutex);
if ( bp->speculative != 0 && bp->numspec <= bundlei ) if ( bp->speculative != 0 && bp->numspec <= bundlei )
{ {
bp->speculative[bundlei] = block->RO.hash2; bp->speculative[bundlei] = block->RO.hash2;

2
includes/iguana_structs.h

@ -183,7 +183,7 @@ struct iguana_zblockRO
} __attribute__((packed)); } __attribute__((packed));
#define iguana_blockfields double PoW; \ #define iguana_blockfields double PoW; \
int32_t height,fpos; uint32_t fpipbits,issued,lag:19,protected:1,peerid:12; \ int32_t height,fpos,datalen; uint32_t fpipbits,issued,lag:19,protected:1,peerid:12; \
uint16_t hdrsi:15,mainchain:1,bundlei:11,valid:1,queued:1,txvalid:1,newtx:1,processed:1; \ uint16_t hdrsi:15,mainchain:1,bundlei:11,valid:1,queued:1,txvalid:1,newtx:1,processed:1; \
UT_hash_handle hh; struct iguana_bundlereq *req; uint8_t *serialized; \ UT_hash_handle hh; struct iguana_bundlereq *req; uint8_t *serialized; \
struct iguana_blockRO RO struct iguana_blockRO RO

Loading…
Cancel
Save