From 21b0052736324d3aff5b09d45168a353258949a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jul 2016 19:00:58 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 116 ++---------------------------------- basilisk/basilisk_DEX.c | 6 +- basilisk/basilisk_bitcoin.c | 109 ++++++++++++++++++++++++++++++++- basilisk/basilisk_ping.c | 2 +- 4 files changed, 117 insertions(+), 116 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index a9fc67811..c584a7c4e 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -80,7 +80,7 @@ uint8_t *get_dataptr(int32_t hdroffset,uint8_t **ptrp,int32_t *datalenp,uint8_t uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag) { - char *sendstr,*hexstr=0; uint8_t *data,hexspace[8192],*allocptr=0,*hexdata; int32_t datalen,hexlen=0; + char *sendstr,*hexstr=0; uint8_t *data,hexspace[4096],*allocptr=0,*hexdata; int32_t datalen,hexlen=0; if ( jobj(sendjson,"symbol") == 0 ) jaddstr(sendjson,"symbol",symbol); if ( (hexstr= jstr(sendjson,"data")) != 0 ) @@ -363,7 +363,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_addr,bits256 hash,cJSON *valsobj,char *hexstr,int32_t blockflag) // client side { - uint32_t nBits = 0; uint8_t space[8192],*allocptr=0,*data = 0; struct basilisk_item *ptr; int32_t datalen = 0; cJSON *retjson; char *retstr=0; + uint32_t nBits = 0; uint8_t space[4096],*allocptr=0,*data = 0; struct basilisk_item *ptr; int32_t datalen = 0; cJSON *retjson; char *retstr=0; data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); ptr = basilisk_requestservice(myinfo,_addr,CMD,blockflag,valsobj,hash,data,datalen,nBits); if ( allocptr != 0 ) @@ -448,7 +448,7 @@ void basilisk_functions(struct iguana_info *coin,int32_t protocol) int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,char *CMD,bits256 *hashes,int32_t num) { - bits256 hash; uint8_t *serialized; int32_t i,len = 0; char *str=0,*retstr,*hexstr,*allocptr=0,space[8192]; bits256 txid; cJSON *vals; + bits256 hash; uint8_t *serialized; int32_t i,len = 0; char *str=0,*retstr,*hexstr,*allocptr=0,space[4096]; bits256 txid; cJSON *vals; if ( virt != 0 && addr != 0 ) { memset(hash.bytes,0,sizeof(hash)); @@ -690,7 +690,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t datalen,char *type,int32_t encrypted) { - uint32_t ipbits,basilisktag; int32_t msglen,len=0; void *ptr = 0; uint8_t space[8192]; bits256 senderpub; struct supernet_info *myinfo = _myinfo; + uint32_t ipbits,basilisktag; int32_t msglen,len=0; void *ptr = 0; uint8_t space[4096]; bits256 senderpub; struct supernet_info *myinfo = _myinfo; if ( encrypted != 0 ) { printf("encrypted p2p\n"); @@ -787,7 +787,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_request *issueR,cJSON *retjson,double hwm) { - cJSON *array,*item; int32_t i,n,m; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS*10]; double metric=0.; + cJSON *array,*item; int32_t i,n,m; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; if ( (array= jarray(&n,retjson,"result")) != 0 ) { for (i=m=0; imessagemutex); myinfo->basilisks.launched = iguana_launch(iguana_coinfind("BTCD"),"basilisks_loop",basilisks_loop,myinfo,IGUANA_PERMTHREAD); } - -#include "../includes/iguana_apidefs.h" -#include "../includes/iguana_apideclares.h" - -HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) -{ - char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; - if ( coin == 0 ) - { - if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) - coin = iguana_coinfind(symbol); - } - if ( coin != 0 ) - { - if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) - basilisktag = rand(); - if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) - timeoutmillis = BASILISK_TIMEOUT; - if ( coin->RELAYNODE != 0 && (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) - { - retstr = ptr->retstr, ptr->retstr = 0; - ptr->finished = (uint32_t)time(NULL); - return(retstr); - } - } - return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) -{ - char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; - if ( coin == 0 ) - { - if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) - coin = iguana_coinfind(symbol); - } - if ( coin != 0 ) - { - if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) - basilisktag = rand(); - if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) - timeoutmillis = BASILISK_TIMEOUT; - if ( coin->RELAYNODE != 0 && (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) - { - retstr = ptr->retstr, ptr->retstr = 0; - ptr->finished = (uint32_t)time(NULL); - return(retstr); - } - } - return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) -{ - char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis,i,retval = -1; uint64_t amount,txfee; cJSON *retarray; - if ( coin == 0 ) - { - if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) - coin = iguana_coinfind(symbol); - } - if ( coin != 0 ) - { - if ( juint(vals,"burn") == 0 ) - jaddnum(vals,"burn",0.0001); - if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) - basilisktag = rand(); - if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) - timeoutmillis = BASILISK_TIMEOUT; - if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) - { - if ( (retstr= ptr->retstr) != 0 ) - { - if ( (amount= j64bits(vals,"satoshis")) == 0 ) - amount = jdouble(vals,"value") * SATOSHIDEN; - if ( (txfee= j64bits(vals,"txfee")) == 0 ) - txfee = coin->chain->txfee; - if ( txfee == 0 ) - txfee = 10000; - retval = -1; - if ( (retarray= cJSON_Parse(retstr)) != 0 ) - { - if ( is_cJSON_Array(retarray) != 0 ) - { - for (i=0; iretstr = 0; - ptr->finished = (uint32_t)time(NULL); - } - } - } - return(retstr); -} -#include "../includes/iguana_apiundefs.h" diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index f55d1284d..2ed525097 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -378,7 +378,7 @@ char *basilisk_respond_swapstatus(struct supernet_info *myinfo,bits256 hash,uint char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32_t requestid,uint32_t quoteid) { - int32_t i,qflag,num=0; cJSON *retjson,*array; struct basilisk_request *requests,*rp; uint8_t space[16384]; + int32_t i,qflag,num=0; cJSON *retjson,*array; struct basilisk_request *requests,*rp; uint8_t space[4096]; array = cJSON_CreateArray(); portable_mutex_lock(&myinfo->DEX_reqmutex); if ( (requests= _basilisk_requests_uniq(myinfo,&num,space,sizeof(space))) != 0 ) @@ -404,7 +404,7 @@ char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32 char *basilisk_respond_accept(struct supernet_info *myinfo,uint32_t requestid,uint32_t quoteid) { - int32_t i,num=0; char *retstr=0; struct basilisk_request *requests,*rp; uint8_t space[16384]; + int32_t i,num=0; char *retstr=0; struct basilisk_request *requests,*rp; uint8_t space[4096]; portable_mutex_lock(&myinfo->DEX_reqmutex); if ( (requests= _basilisk_requests_uniq(myinfo,&num,space,sizeof(space))) != 0 ) { @@ -512,7 +512,7 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) hash = myinfo->myaddr.persistent; printf("service.(%s)\n",jprint(vals,0)); { - uint8_t serialized[522]; struct basilisk_request R; cJSON *reqjson; + uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; memset(&R,0,sizeof(R)); if ( basilisk_request_create(&R,vals,hash,juint(vals,"timestamp")) == 0 ) { diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 774da844e..c26ca5246 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -641,7 +641,7 @@ int32_t basilisk_vins_validate(struct supernet_info *myinfo,struct iguana_info * void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) { - uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t oplen,offset,numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; + uint8_t buf[4096]; int32_t oplen,offset,numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; vins = 0; changeaddr = jstr(valsobj,"changeaddr"); if ( (amount= j64bits(valsobj,"satoshis")) == 0 ) @@ -965,3 +965,110 @@ cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exch return(newjson); } #endif + + +#include "../includes/iguana_apidefs.h" +#include "../includes/iguana_apideclares.h" + +HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) +{ + char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; + if ( coin == 0 ) + { + if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) + coin = iguana_coinfind(symbol); + } + if ( coin != 0 ) + { + if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) + basilisktag = rand(); + if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) + timeoutmillis = BASILISK_TIMEOUT; + if ( coin->RELAYNODE != 0 && (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) + { + retstr = ptr->retstr, ptr->retstr = 0; + ptr->finished = (uint32_t)time(NULL); + return(retstr); + } + } + return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); +} + +HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) +{ + char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; + if ( coin == 0 ) + { + if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) + coin = iguana_coinfind(symbol); + } + if ( coin != 0 ) + { + if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) + basilisktag = rand(); + if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) + timeoutmillis = BASILISK_TIMEOUT; + if ( coin->RELAYNODE != 0 && (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) + { + retstr = ptr->retstr, ptr->retstr = 0; + ptr->finished = (uint32_t)time(NULL); + return(retstr); + } + } + return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1)); +} + +HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) +{ + char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis,i,retval = -1; uint64_t amount,txfee; cJSON *retarray; + if ( coin == 0 ) + { + if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) + coin = iguana_coinfind(symbol); + } + if ( coin != 0 ) + { + if ( juint(vals,"burn") == 0 ) + jaddnum(vals,"burn",0.0001); + if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) + basilisktag = rand(); + if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) + timeoutmillis = BASILISK_TIMEOUT; + if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) + { + if ( (retstr= ptr->retstr) != 0 ) + { + if ( (amount= j64bits(vals,"satoshis")) == 0 ) + amount = jdouble(vals,"value") * SATOSHIDEN; + if ( (txfee= j64bits(vals,"txfee")) == 0 ) + txfee = coin->chain->txfee; + if ( txfee == 0 ) + txfee = 10000; + retval = -1; + if ( (retarray= cJSON_Parse(retstr)) != 0 ) + { + if ( is_cJSON_Array(retarray) != 0 ) + { + for (i=0; iretstr = 0; + ptr->finished = (uint32_t)time(NULL); + } + } + } + return(retstr); +} +#include "../includes/iguana_apiundefs.h" diff --git a/basilisk/basilisk_ping.c b/basilisk/basilisk_ping.c index 2e76dd3cf..d43c37645 100755 --- a/basilisk/basilisk_ping.c +++ b/basilisk/basilisk_ping.c @@ -26,7 +26,7 @@ int32_t baslisk_relay_report(struct supernet_info *myinfo,uint8_t *data,int32_t int32_t basilisk_blocksend(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,struct iguana_peer *addr,int32_t height) { - int32_t blocklen; bits256 hash2; uint8_t *data = 0; char str[65],strbuf[8192],*blockstr,*allocptr = 0; struct iguana_block *block; + int32_t blocklen; bits256 hash2; uint8_t *data = 0; char str[65],strbuf[4096],*blockstr,*allocptr = 0; struct iguana_block *block; hash2 = iguana_blockhash(virt,height); if ( (block= iguana_blockfind("bsend",virt,hash2)) != 0 ) {