Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
faed022e4e
  1. 4
      basilisk/basilisk_MSG.c
  2. 1
      iguana/iguana_msg.c
  3. 17
      iguana/iguana_payments.c
  4. 2
      iguana/iguana_ramchain.c
  5. 10
      iguana/iguana_realtime.c
  6. 2
      includes/iguana_funcs.h
  7. 4
      includes/iguana_structs.h

4
basilisk/basilisk_MSG.c

@ -174,7 +174,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
free(retstr); free(retstr);
} }
if ( vals != 0 && juint(vals,"fanout") == 0 ) if ( vals != 0 && juint(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)); jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+2);
return(basilisk_standardservice("OUT",myinfo,0,hash,vals,hexstr,0)); return(basilisk_standardservice("OUT",myinfo,0,hash,vals,hexstr,0));
} }
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"
@ -188,7 +188,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
jaddnum(valsobj,"channel",channel); jaddnum(valsobj,"channel",channel);
if ( msgid == 0 ) if ( msgid == 0 )
msgid = (uint32_t)time(NULL); msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"fanout",(int32_t)sqrt(NUMRELAYS)+1); jaddnum(valsobj,"fanout",(int32_t)sqrt(NUMRELAYS)+2);
jaddnum(valsobj,"msgid",msgid); jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration); jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"sender",myinfo->myaddr.persistent); jaddbits256(valsobj,"sender",myinfo->myaddr.persistent);

1
iguana/iguana_msg.c

@ -582,6 +582,7 @@ int32_t iguana_rwtx(uint8_t zcash,int32_t rwflag,struct OS_memspace *mem,uint8_t
int32_t i,n,len = 0; uint8_t *txstart = serialized; char txidstr[65]; int32_t i,n,len = 0; uint8_t *txstart = serialized; char txidstr[65];
if ( maxsize < sizeof(msg->version) ) if ( maxsize < sizeof(msg->version) )
return(-1); return(-1);
msg->serialized = serialized;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->version),&msg->version); len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->version),&msg->version);
if ( hastimestamp != 0 ) if ( hastimestamp != 0 )
{ {

17
iguana/iguana_payments.c

@ -833,13 +833,23 @@ THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message)
HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose) HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
{ {
struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_block *block; bits256 hash2; struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len=0,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_block *block; bits256 hash2; struct iguana_RTtxid *RTptr;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 ) HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 )
{ {
checktxid = RTptr->txid;
height = RTptr->height;
len = RTptr->txlen;
memcpy(coin->blockspace,RTptr->rawtxbytes,len);
}
else if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 )
{
len = iguana_ramtxbytes(coin,coin->blockspace,coin->blockspacesize,&checktxid,tx,height,0,0,0);
}
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
if ( (len= iguana_ramtxbytes(coin,coin->blockspace,coin->blockspacesize,&checktxid,tx,height,0,0,0)) > 0 ) if ( len > 0 )
{ {
txbytes = calloc(1,len*2+1); txbytes = calloc(1,len*2+1);
init_hexbytes_noT(txbytes,coin->blockspace,len); init_hexbytes_noT(txbytes,coin->blockspace,len);
@ -890,7 +900,6 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
} else jaddstr(retjson,"error","cant find blockhash"); } else jaddstr(retjson,"error","cant find blockhash");
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
} else printf("height.%d\n",height);
} }
return(clonestr("{\"error\":\"cant find txid\"}")); return(clonestr("{\"error\":\"cant find txid\"}"));
} }

2
iguana/iguana_ramchain.c

@ -2813,7 +2813,7 @@ int32_t iguana_RTramchaindata(struct supernet_info *myinfo,struct iguana_info *c
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];
RTptr = iguana_RTtxid_create(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp); RTptr = iguana_RTtxid_create(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp,tx->serialized,tx->allocsize);
if ( polarity > 0 ) if ( polarity > 0 )
{ {
if ( iter == 0 ) if ( iter == 0 )

10
iguana/iguana_realtime.c

@ -485,6 +485,8 @@ void iguana_RTtxid_free(struct iguana_RTtxid *RTptr)
for (i=0; i<RTptr->numvins; i++) for (i=0; i<RTptr->numvins; i++)
if ( RTptr->spends[i] != 0 ) if ( RTptr->spends[i] != 0 )
free(RTptr->spends[i]); free(RTptr->spends[i]);
if ( RTptr->rawtxbytes != 0 )
free(RTptr->rawtxbytes);
free(RTptr); free(RTptr);
} }
@ -715,7 +717,7 @@ void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct
//fprintf(stderr,","); //fprintf(stderr,",");
} }
struct iguana_RTtxid *iguana_RTtxid_create(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 *iguana_RTtxid_create(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,uint8_t *serialized,int32_t txlen)
{ {
struct iguana_RTtxid *RTptr; char str[65]; struct iguana_RTtxid *RTptr; char str[65];
if ( block == 0 || block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) ) if ( block == 0 || block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
@ -740,6 +742,12 @@ struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguan
RTptr->version = version; RTptr->version = version;
RTptr->timestamp = timestamp; RTptr->timestamp = timestamp;
RTptr->unspents = (void *)&RTptr->spends[numvins]; RTptr->unspents = (void *)&RTptr->spends[numvins];
if ( txlen > 0 )
{
RTptr->rawtxbytes = malloc(txlen);
RTptr->txlen = txlen;
memcpy(RTptr->rawtxbytes,serialized,txlen);
}
HASH_ADD_KEYPTR(hh,coin->RTdataset,RTptr->txid.bytes,sizeof(RTptr->txid),RTptr); HASH_ADD_KEYPTR(hh,coin->RTdataset,RTptr->txid.bytes,sizeof(RTptr->txid),RTptr);
if ( 0 && strcmp("BTC",coin->symbol) != 0 ) if ( 0 && strcmp("BTC",coin->symbol) != 0 )
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); 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);

2
includes/iguana_funcs.h

@ -551,7 +551,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); 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_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
int32_t iguana_RTramchaindata(struct supernet_info *myinfo,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 supernet_info *myinfo,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_create(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 *iguana_RTtxid_create(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,uint8_t *serialized,int32_t txlen);
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); 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);
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); 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

@ -137,6 +137,7 @@ struct iguana_msgtx
bits256 txid; bits256 txid;
int32_t allocsize,timestamp,numinputs,numoutputs; int32_t allocsize,timestamp,numinputs,numoutputs;
int64_t inputsum,outputsum,txfee; int64_t inputsum,outputsum,txfee;
uint8_t *serialized;
} __attribute__((packed)); } __attribute__((packed));
struct iguana_msgjoinsplit struct iguana_msgjoinsplit
@ -414,8 +415,9 @@ struct iguana_RTtxid
{ {
UT_hash_handle hh; struct iguana_info *coin; struct iguana_block *block; UT_hash_handle hh; struct iguana_info *coin; struct iguana_block *block;
bits256 txid; bits256 txid;
int32_t height,txi,txn_count,numvouts,numvins; int32_t height,txi,txn_count,numvouts,numvins,txlen;
uint32_t locktime,version,timestamp; uint32_t locktime,version,timestamp;
uint8_t *rawtxbytes;
struct iguana_RTunspent **unspents; struct iguana_RTunspent **unspents;
struct iguana_RTspend *spends[]; struct iguana_RTspend *spends[];
}; };

Loading…
Cancel
Save