Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
5ff24b6fd2
  1. 6
      iguana/iguana_ramchain.c
  2. 59
      iguana/iguana_realtime.c
  3. 2
      includes/iguana_funcs.h
  4. 4
      includes/iguana_structs.h

6
iguana/iguana_ramchain.c

@ -2791,7 +2791,7 @@ int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDAT
for (i=0; i<txn_count; i++,ramchain->H.txidind++)
{
tx = &txarray[i];
RTptr = iguana_RTtxid(coin,block,polarity,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp);
RTptr = 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++)
{
script = tx->vouts[j].pk_script;
@ -2813,10 +2813,10 @@ int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDAT
for (i=0; i<txn_count; i++,ramchain->H.txidind++)
{
tx = &txarray[i];
RTptr = iguana_RTtxid(coin,block,polarity,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp);
RTptr = 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_in; j++)
{
iguana_RTspend(coin,RTptr,block,polarity,tx->vins[i].vinscript,tx->vins[i].scriptlen,tx->txid,j,tx->vins[j].prev_hash,tx->vins[j].prev_vout);
iguana_RTspend(coin,RTptr,block,polarity,tx->vins[j].vinscript,tx->vins[j].scriptlen,tx->txid,j,tx->vins[j].prev_hash,tx->vins[j].prev_vout);
}
}
iguana_ramchain_free(coin,ramchain,0);

59
iguana/iguana_realtime.c

@ -464,14 +464,40 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info *
return(flag);
}
void iguana_RTcoinaddr(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,uint8_t *rmd160,int64_t value)
{
char coinaddr[65];
bitcoin_address(coinaddr,coin->chain->pubtype,rmd160,20);
printf("%lld %s %.8f\n",(long long)polarity,coinaddr,dstr(value));
}
void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value)
{
int32_t i;
int32_t i; struct iguana_RTunspent *unspent; char str[65];
if ( RTptr != 0 )
{
if ( bits256_cmp(RTptr->txid,txid) == 0 )
{
if ( (unspent= RTptr->unspents[vout]) == 0 )
{
if ( polarity > 0 )
{
unspent = calloc(1,sizeof(*unspent) + scriptlen);
unspent->value = value;
unspent->scriptlen = scriptlen;
memcpy(unspent->rmd160,rmd160,sizeof(unspent->rmd160));
memcpy(unspent->script,script,scriptlen);
} else printf("iguana_RTunspent missing vout.%d ptr\n",vout);
}
else
{
if ( memcmp(rmd160,unspent->rmd160,sizeof(unspent->rmd160)) != 0 || value != unspent->value || scriptlen != unspent->scriptlen || memcmp(unspent->script,script,scriptlen) != 0 )
{
printf("iguana_RTunspent.%d of %d mismatch %s\n",vout,RTptr->numvouts,bits256_str(str,RTptr->txid));
return;
}
}
iguana_RTcoinaddr(coin,RTptr,block,polarity,rmd160,value);
} else printf("iguana_RTunspent txid mismatch %llx != %llx\n",(long long)RTptr->txid.txid,(long long)txid.txid);
}
else
@ -484,8 +510,7 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struc
void iguana_RTspend(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout)
{
struct iguana_RTspend *spend;
char str[65],str2[65];
struct iguana_RTspend *spend; struct iguana_RTtxid *spentRTptr; struct iguana_RTunspent *unspent; char str[65],str2[65];
if ( RTptr != 0 )
{
if ( bits256_cmp(RTptr->txid,txid) == 0 )
@ -494,9 +519,28 @@ void iguana_RTspend(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct
{
if ( polarity > 0 )
{
spend = calloc(1,sizeof(*spend) + scriptlen);
spend->prev_hash = prev_hash;
spend->prev_vout = prev_vout;
spend->scriptlen = scriptlen;
memcpy(spend->vinscript,script,scriptlen);
} else printf("iguana_RTspend missing vini.%d ptr\n",vini);
}
else
{
if ( bits256_cmp(prev_hash,spend->prev_hash) != 0 || prev_vout != spend->prev_vout || scriptlen != spend->scriptlen || memcmp(spend->vinscript,script,scriptlen) != 0 )
{
printf("RTspend.%d of %d mismatch %s\n",vini,RTptr->numvins,bits256_str(str,RTptr->txid));
return;
}
}
HASH_FIND(hh,coin->RTdataset,prev_hash.bytes,sizeof(prev_hash),spentRTptr);
if ( spentRTptr != 0 )
{
if ( (unspent= spentRTptr->unspents[prev_vout]) != 0 )
iguana_RTcoinaddr(coin,RTptr,block,polarity,unspent->rmd160,unspent->value);
else printf("iguana_RTspend null unspent.(%s).%d\n",bits256_str(str,prev_hash),prev_vout);
} else printf("iguana_RTspend cant find spentRTptr.(%s)\n",bits256_str(str,prev_hash));
} else printf("iguana_RTspend txid mismatch %llx != %llx\n",(long long)RTptr->txid.txid,(long long)txid.txid);
} else printf("null rtptr? %s vini.%d spend.(%s/v%d) %lld\n",bits256_str(str,txid),vini,bits256_str(str2,prev_hash),prev_vout,(long long)polarity);
}
@ -523,13 +567,16 @@ void iguana_RTdataset_free(struct iguana_info *coin)
}
}
struct iguana_RTtxid *iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp)
struct iguana_RTtxid *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)
{
struct iguana_RTtxid *RTptr; char str[65];
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr == 0 )
{
RTptr = calloc(1,sizeof(*RTptr) + sizeof(void *)*numvins + sizeof(void *)*numvouts);
RTptr->txi = txi, RTptr->txn_count = txn_count;
RTptr->coin = coin;
RTptr->block = block;
RTptr->txid = txid;
RTptr->txn_count = txn_count;
RTptr->numvouts = numvouts;

2
includes/iguana_funcs.h

@ -540,7 +540,7 @@ int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fil
struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *btcd,uint32_t ipbits);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
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);
struct iguana_RTtxid *iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp);
struct iguana_RTtxid *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_RTspend(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout);
void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value);

4
includes/iguana_structs.h

@ -396,9 +396,9 @@ struct iguana_RTunspent
struct iguana_RTtxid
{
UT_hash_handle hh;
UT_hash_handle hh; struct iguana_info *coin; struct iguana_block *block;
bits256 txid;
int32_t txn_count,numvouts,numvins;
int32_t txi,txn_count,numvouts,numvins;
uint32_t locktime,version,timestamp;
struct iguana_RTunspent **unspents;
struct iguana_RTspend *spends[];

Loading…
Cancel
Save