From 59fa6d43d9b326369dd57c75dfd59c58c933f28a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Jul 2016 07:59:14 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 45 +++++++++++++++++++++++++++++++++++-- basilisk/basilisk_bitcoin.c | 37 ------------------------------ iguana/tests/rawtx | 2 +- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 4c7b3ca3f..ca28d7213 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -202,7 +202,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ //printf("skip non-relay.(%s)\n",addr->ipaddr); continue; } - printf("send to other relay.(%s)\n",addr->ipaddr); + ///printf("send to other relay.(%s)\n",addr->ipaddr); } for (s=0; sipbits ) @@ -297,6 +297,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,struct i if ( blockflag != 0 ) { portable_mutex_lock(&myinfo->basilisk_mutex); + printf("HASH_ADD.%p\n",pending); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(basilisktag),pending); portable_mutex_unlock(&myinfo->basilisk_mutex); //queue_enqueue("issuedQ",&myinfo->basilisks.issued,&pending->DL,0); @@ -516,6 +517,7 @@ void basilisk_result(struct supernet_info *myinfo,char *remoteaddr,uint32_t basi { portable_mutex_lock(&myinfo->basilisk_mutex); HASH_FIND(hh,myinfo->basilisks.issued,&basilisktag,sizeof(basilisktag),pending); + printf("HASH_FIND.%p\n",pending); portable_mutex_unlock(&myinfo->basilisk_mutex); if ( pending != 0 && retstr != 0 ) { @@ -869,8 +871,10 @@ void basilisks_loop(void *arg) { if ( pending != 0 && (pending->finished != 0 || OS_milliseconds() > pending->expiration+60000) ) { + printf("HASH_DELETE.(%p)\n",pending); HASH_DELETE(hh,myinfo->basilisks.issued,pending); - free(pending); + //memset(pending,0,sizeof(*pending)); + //free(pending); } } portable_mutex_unlock(&myinfo->basilisk_mutex); @@ -925,3 +929,40 @@ void basilisks_init(struct supernet_info *myinfo) portable_mutex_init(&myinfo->messagemutex); 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) +{ + return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); +} + +HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) +{ + 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; + 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 ( juint(vals,"burn") == 0 ) + jaddnum(vals,"burn",0.0001); + if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) + timeoutmillis = BASILISK_TIMEOUT; + if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) + { + retstr = ptr->retstr; + } + } + return(retstr); +} +#include "../includes/iguana_apiundefs.h" diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 7f82c770b..a2a3c46a9 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -897,40 +897,3 @@ 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) -{ - return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) -{ - 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; - if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) - { - if ( (coin= iguana_coinfind(symbol)) != 0 ) - { - if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) - basilisktag = rand(); - if ( juint(vals,"burn") == 0 ) - jaddnum(vals,"burn",0.0001); - if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) - timeoutmillis = BASILISK_TIMEOUT; - if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) - { - retstr = ptr->retstr; - } - if ( ptr != &Lptr ) - free(ptr); - } - } - return(retstr); -} -#include "../includes/iguana_apiundefs.h" diff --git a/iguana/tests/rawtx b/iguana/tests/rawtx index c847a226a..84b5b8ab6 100755 --- a/iguana/tests/rawtx +++ b/iguana/tests/rawtx @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"activecoin\":\"BTC\",\"agent\":\"basilisk\",\"method\":\"rawtx\",\"vals\":{\"changeaddr\":\"1FNhoaBYzf7safMBjoCsJYgxtah3K95sep\",\"addresses\":[\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\"],\"timeout\":15000,\"satoshis\":\"20000\",\"spendscript\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"agent\":\"basilisk\",\"method\":\"rawtx\",\"vals\":{\"changeaddr\":\"1FNhoaBYzf7safMBjoCsJYgxtah3K95sep\",\"addresses\":[\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\"],\"timeout\":15000,\"satoshis\":\"20000\",\"spendscript\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}}"