Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
2ff5dffc06
  1. 11
      datachain/datachain.c
  2. 20
      iguana/iguana_realtime.c
  3. 8
      iguana/iguana_recv.c

11
datachain/datachain.c

@ -41,6 +41,7 @@ uint32_t datachain_checkpoint(struct supernet_info *myinfo,struct iguana_info *c
int32_t datachain_events_rewind(struct supernet_info *myinfo,int32_t ordered,struct datachain_info *dPoW,int32_t height,uint32_t hdrsi,uint32_t unspentind)
{
uint64_t hdrsi_unspentind; int32_t i;
printf("datachain_events_rewind\n");
if ( dPoW->numevents > 0 )
{
datachain_events_sort(dPoW);
@ -57,6 +58,7 @@ int32_t datachain_events_rewind(struct supernet_info *myinfo,int32_t ordered,str
int32_t datachain_checkpoint_update(struct supernet_info *myinfo,struct iguana_info *coin,uint32_t timestamp)
{
int32_t i,num,n,lastheight; bits256 *tree,hash2,lasthash2,merkle; struct iguana_block *block;
printf("datachain_checkpoint_update\n");
if ( coin->lastcheckpoint <= coin->blocks.hwmchain.height )
{
num = (coin->blocks.hwmchain.height - coin->lastcheckpoint) + 1;
@ -97,6 +99,7 @@ int32_t datachain_checkpoint_update(struct supernet_info *myinfo,struct iguana_i
void datachain_BTC_clock(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *btc,int32_t height,uint32_t hdrsi,uint32_t unspentind,uint32_t timestamp)
{
int32_t retval; struct iguana_info *btcd = iguana_coinfind("BTCD");
printf("datachain_BTC_clock\n");
if ( (retval= datachain_eventadd(myinfo,ordered,&myinfo->dPoW.BTC,DATACHAIN_ISBTC,0)) < 0 )
{
myinfo->dPoW.BTC.numevents = datachain_events_rewind(myinfo,ordered,&myinfo->dPoW.BTC,height,hdrsi,unspentind);
@ -115,6 +118,7 @@ void datachain_BTC_clock(struct supernet_info *myinfo,int32_t ordered,struct igu
void datachain_KOMODO_newblock(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *btcd,int32_t height,uint32_t hdrsi,uint32_t unspentind,uint32_t timestamp)
{
int32_t retval; struct iguana_info *virt,*tmp;
printf("datachain_KOMODO_newblock\n");
if ( (retval= datachain_eventadd(myinfo,ordered,&myinfo->dPoW.BTCD,DATACHAIN_ISKOMODO,0)) < 0 )
{
myinfo->dPoW.BTCD.numevents = datachain_events_rewind(myinfo,ordered,&myinfo->dPoW.BTCD,height,hdrsi,unspentind);
@ -137,6 +141,7 @@ void datachain_KOMODO_newblock(struct supernet_info *myinfo,int32_t ordered,stru
void datachain_virt_newblock(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *virt,int32_t height,uint32_t hdrsi,uint32_t unspentind,uint32_t timestamp)
{
int32_t retval;
printf("datachain_virt_newblock\n");
if ( (retval= datachain_eventadd(myinfo,ordered,&virt->dPoW,0,0)) < 0 )
{
virt->dPoW.numevents = datachain_events_rewind(myinfo,ordered,&virt->dPoW,height,hdrsi,unspentind);
@ -225,6 +230,7 @@ void datachain_opreturn(struct supernet_info *myinfo,int32_t ordered,struct igua
uint32_t hdrsi,unspentind; struct datachain_event *event;
hdrsi = (uint32_t)(hdrsi_unspentind >> 32);
unspentind = (uint32_t)hdrsi_unspentind;
printf("datachain_opreturn\n");
if ( btc_or_btcd == DATACHAIN_ISBTC ) // BTC
{
if ( opreturn == 0 )
@ -267,6 +273,7 @@ void datachain_opreturn(struct supernet_info *myinfo,int32_t ordered,struct igua
int32_t iguana_opreturn(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int64_t crypto777_payment,int32_t height,uint64_t hdrsi_unspentind,int64_t burned,uint32_t fileid,uint64_t scriptpos,uint32_t scriptlen)
{
uint8_t type,scriptspace[IGUANA_MAXSCRIPTSIZE],opreturn[8192]; char fname[1024]; uint32_t oplen=0; int32_t btc_or_btcd=0,len = -1; struct vin_info V;
printf("iguana_opreturn\n");
if ( strcmp("BTC",coin->symbol) == 0 )
btc_or_btcd = DATACHAIN_ISBTC;
else if ( strcmp("BTCD",coin->symbol) == 0 )
@ -314,9 +321,13 @@ void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct
int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t value,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout)
{
if ( memcmp(rmd160,CRYPTO777_RMD160,20) == 0 )
{
crypto777_payment += value;
printf("datachain_update crypto777 %.8f += %.8f\n",dstr(crypto777_payment),dstr(value));
}
else if ( crypto777_payment != 0 && (type == IGUANA_SCRIPT_OPRETURN || type == IGUANA_SCRIPT_3of3 || type == IGUANA_SCRIPT_2of2 || type == IGUANA_SCRIPT_1of1) )
{
printf("datachain_update opreturn\n");
iguana_opreturn(myinfo,ordered,coin,timestamp,bp,crypto777_payment,height,hdrsi_unspentind,value,fileid,scriptpos,scriptlen);
} else datachain_update_spend(myinfo,ordered,coin,timestamp,bp,height,txid,vout,rmd160,value);
return(crypto777_payment);

20
iguana/iguana_realtime.c

@ -514,7 +514,7 @@ struct iguana_RTunspent *iguana_RTunspent_create(uint8_t *rmd160,int64_t value,u
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; struct iguana_RTunspent *unspent; char str[65];
printf("iguana_RTunspent.%lld %s vout.%d %.8f\n",(long long)polarity,coinaddr,vout,dstr(value));
//printf("iguana_RTunspent.%lld %s vout.%d %.8f\n",(long long)polarity,coinaddr,vout,dstr(value));
if ( RTptr != 0 )
{
if ( bits256_cmp(RTptr->txid,txid) == 0 )
@ -552,8 +552,8 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struc
void iguana_RTspend(struct supernet_info *myinfo,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; struct iguana_RTtxid *spentRTptr; struct iguana_RTunspent *unspent=0; char str[65],str2[65],coinaddr[64]; uint8_t rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t spendlen,height; uint64_t value;
printf("RTspend %s vini.%d spend.(%s/v%d) %lld\n",bits256_str(str,txid),vini,bits256_str(str2,prev_hash),prev_vout,(long long)polarity);
struct iguana_RTspend *spend; struct iguana_RTtxid *spentRTptr; struct iguana_RTunspent *unspent=0; char str[65],str2[65],coinaddr[64]; uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t spendlen,height; uint64_t value;
//printf("RTspend %s vini.%d spend.(%s/v%d) %lld\n",bits256_str(str,txid),vini,bits256_str(str2,prev_hash),prev_vout,(long long)polarity);
if ( vini == 0 && bits256_nonz(prev_hash) == 0 && prev_vout < 0 )
return;
if ( RTptr != 0 )
@ -594,13 +594,17 @@ void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct
{
if ( iguana_unspentindfind(myinfo,coin,coinaddr,spendscript,&spendlen,&value,&height,prev_hash,prev_vout,coin->bundlescount,0) == 0 )
printf("iguana_RTspend cant find spentRTptr.(%s) search history\n",bits256_str(str,prev_hash));
else unspent = iguana_RTunspent_create(rmd160,value,spendscript,spendlen);
else
{
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
//printf("found unspentind (%s %.8f).%d spendlen.%d\n",coinaddr,dstr(value),addrtype,spendlen);
unspent = iguana_RTunspent_create(rmd160,value,spendscript,spendlen);
}
}
if ( unspent != 0 )
{
bitcoin_address(coinaddr,coin->chain->pubtype,unspent->rmd160,sizeof(unspent->rmd160));
iguana_RTcoinaddr(coin,RTptr,block,polarity,coinaddr,unspent->rmd160,1,unspent->value,unspent);
printf("spent %s\n",coinaddr);
unspent->spend = spend;
unspent->spentflag = (polarity > 0);
}
@ -790,14 +794,14 @@ int32_t iguana_RTiterate(struct supernet_info *myinfo,struct iguana_info *coin,i
iguana_meminit(&coin->RThashmem,"RThashmem",0,IGUANA_MAXPACKETSIZE * 2,0);
iguana_memreset(&coin->RTrawmem), iguana_memreset(&coin->RTmem), iguana_memreset(&coin->RThashmem);
memset(&txdata,0,sizeof(txdata));
extern int32_t debugtest;
debugtest = 1;
//extern int32_t debugtest;
//debugtest = 1;
if ( (n= iguana_gentxarray(coin,&coin->RTrawmem,&txdata,&len,serialized,recvlen)) > 0 )
{
iguana_RTramchaindata(myinfo,coin,&coin->RTmem,&coin->RThashmem,polarity,block,coin->RTrawmem.ptr,numtx);
return(0);
} else printf("gentxarray n.%d RO.txn_count.%d recvlen.%d\n",n,numtx,recvlen);
debugtest = 0;
//debugtest = 0;
iguana_RTreset(coin);
return(-1);
}

8
iguana/iguana_recv.c

@ -517,7 +517,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish <= 1 )
break;
if ( i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize > 0 )
if ( i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize )
{
portable_mutex_lock(&coin->RTmutex);
iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx,0);
@ -816,7 +816,7 @@ int32_t iguana_height_estimate(struct iguana_info *coin,struct iguana_block **ma
if ( tmp->mainchain != 0 && tmp->height >= 0 )
{
char str[65];
if ( n > 0 && coin->RTheight > 0 )
if ( 0 && n > 0 && coin->RTheight > 0 )
printf("%s M.%d dist.%d -> %d\n",bits256_str(str,block->RO.hash2),tmp->height,n,tmp->height+n);
*mainchainp = tmp;
return(tmp->height + n);
@ -1699,8 +1699,8 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
height = bp->bundleheight + bundlei;
bp->issued[bundlei] = 1;
}
req->height = height;
req->bundlei = bundlei;
req->height = -1; //height;
req->bundlei = -1; //bundlei;
char str2[65];
//printf("%s %s %s [%d:%d] %d %s %d numranked.%d qsize.%d\n",coin->symbol,argstr,str,bp!=0?bp->hdrsi:-1,bundlei,req->height,bits256_str(str2,hash2),coin->blocks.recvblocks,coin->peers->numranked,queue_size(Q));
if ( (n= queue_size(Q)) > 100000 )

Loading…
Cancel
Save