Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
59fa6d43d9
  1. 45
      basilisk/basilisk.c
  2. 37
      basilisk/basilisk_bitcoin.c
  3. 2
      iguana/tests/rawtx

45
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); //printf("skip non-relay.(%s)\n",addr->ipaddr);
continue; continue;
} }
printf("send to other relay.(%s)\n",addr->ipaddr); ///printf("send to other relay.(%s)\n",addr->ipaddr);
} }
for (s=0; s<n; s++) for (s=0; s<n; s++)
if ( alreadysent[s] == addr->ipbits ) if ( alreadysent[s] == addr->ipbits )
@ -297,6 +297,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,struct i
if ( blockflag != 0 ) if ( blockflag != 0 )
{ {
portable_mutex_lock(&myinfo->basilisk_mutex); portable_mutex_lock(&myinfo->basilisk_mutex);
printf("HASH_ADD.%p\n",pending);
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(basilisktag),pending); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(basilisktag),pending);
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
//queue_enqueue("issuedQ",&myinfo->basilisks.issued,&pending->DL,0); //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); portable_mutex_lock(&myinfo->basilisk_mutex);
HASH_FIND(hh,myinfo->basilisks.issued,&basilisktag,sizeof(basilisktag),pending); HASH_FIND(hh,myinfo->basilisks.issued,&basilisktag,sizeof(basilisktag),pending);
printf("HASH_FIND.%p\n",pending);
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
if ( pending != 0 && retstr != 0 ) 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) ) if ( pending != 0 && (pending->finished != 0 || OS_milliseconds() > pending->expiration+60000) )
{ {
printf("HASH_DELETE.(%p)\n",pending);
HASH_DELETE(hh,myinfo->basilisks.issued,pending); HASH_DELETE(hh,myinfo->basilisks.issued,pending);
free(pending); //memset(pending,0,sizeof(*pending));
//free(pending);
} }
} }
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
@ -925,3 +929,40 @@ void basilisks_init(struct supernet_info *myinfo)
portable_mutex_init(&myinfo->messagemutex); portable_mutex_init(&myinfo->messagemutex);
myinfo->basilisks.launched = iguana_launch(iguana_coinfind("BTCD"),"basilisks_loop",basilisks_loop,myinfo,IGUANA_PERMTHREAD); 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"

37
basilisk/basilisk_bitcoin.c

@ -897,40 +897,3 @@ cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exch
return(newjson); return(newjson);
} }
#endif #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"

2
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\"}}"

Loading…
Cancel
Save