From e13b89517e81dcb16e857d6a0a732c3fb8fff335 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Jul 2016 15:25:36 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 2 +- basilisk/basilisk_DEX.c | 9 ++++++++- includes/iguana_structs.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index dfd7f7bb5..e2ae814d8 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -752,7 +752,7 @@ void basilisks_loop(void *arg) //for (i=0; iRELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 ) // basilisk_bitcoinscan(coin,blockspace,&RAWMEM); - if ( (rand() % 10) == 0 ) + if ( (rand() % 10) == 0 && time(NULL) < myinfo->DEXactive ) basilisk_requests_poll(myinfo); now = (uint32_t)time(NULL); portable_mutex_lock(&myinfo->messagemutex); diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index db7fa8e4c..cb7e81183 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -480,6 +480,7 @@ STRING_ARG(InstantDEX,available,source) HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) { cJSON *msgobj = cJSON_CreateObject(); + myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME; jadd64bits(msgobj,"min",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN); jaddnum(msgobj,"auto",juint(vals,"autoflag")); jadd(vals,"message",msgobj); @@ -493,12 +494,14 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) INT_ARG(InstantDEX,automatched,requestid) { // return quoteid + myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME; return(clonestr("{\"result\":\"automatched not yet\"}")); } INT_ARG(InstantDEX,incoming,requestid) { cJSON *vals; char *retstr; + myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME; if ( myinfo->RELAYID >= 0 ) return(basilisk_respond_requests(myinfo,myinfo->myaddr.persistent,requestid,0)); else @@ -515,6 +518,7 @@ INT_ARG(InstantDEX,incoming,requestid) TWO_INTS(InstantDEX,swapstatus,requestid,quoteid) { cJSON *vals; char *retstr; + myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME; if ( myinfo->RELAYID >= 0 ) return(basilisk_respond_swapstatus(myinfo,myinfo->myaddr.persistent,requestid,quoteid)); else @@ -532,6 +536,7 @@ TWO_INTS(InstantDEX,swapstatus,requestid,quoteid) TWO_INTS(InstantDEX,accept,requestid,quoteid) { struct basilisk_request R,*other; cJSON *vals,*retjson; char *retstr,*msgjsonstr = "{\"state\":1}"; + myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME; if ( myinfo->RELAYID >= 0 ) return(basilisk_respond_accept(myinfo,requestid,quoteid,msgjsonstr)); else @@ -570,7 +575,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk { int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1,autoflag=0; cJSON *statejson,*msgobj=0; uint64_t destamount,minamount = 0,maxamount = 0; uint32_t pendingid,statebits; struct basilisk_swap *active; double metric = 0.; memset(issueR,0,sizeof(*issueR)); - printf("need to verify null quoteid is list[0]\n"); + printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 ) pendingid = active->req.quoteid; if ( bits256_cmp(myinfo->myaddr.persistent,list[0].hash) == 0 ) // my request @@ -611,11 +616,13 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk } } else noquoteflag++; } + printf("myrequest.%d pendingid.%d noquoteflag.%d havequoteflag.%d\n",myrequest,pendingid,noquoteflag,havequoteflag); if ( myrequest == 0 && pendingid == 0 && noquoteflag != 0 ) { double retvals[4],aveprice; aveprice = instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,dstr(list[0].srcamount)); destamount = 0.99 * aveprice * list[0].srcamount; + printf("destamount %.8f aveprice %.8f minamount %.8f\n",dstr(destamount),aveprice,dstr(minamount)); if ( destamount >= maxamount && destamount >= minamount ) { metric = 1.; diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index a9567a045..8dcc1461e 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -457,7 +457,7 @@ struct supernet_info char ipaddr[64],NXTAPIURL[512],secret[4096],rpcsymbol[64],handle[1024],permanentfile[1024]; char *decryptstr; int32_t maxdelay,IAMRELAY,publicRPC,basilisk_busy,genesisresults; - uint32_t expiration,dirty; + uint32_t expiration,dirty,DEXactive; uint16_t argport,rpcport; struct basilisk_info basilisks; struct exchange_info *tradingexchanges[SUPERNET_MAXEXCHANGES]; int32_t numexchanges;