diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index c9f108330..ac1c55be2 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -857,6 +857,7 @@ void basilisks_loop(void *arg) } } notary = iguana_coinfind("NOTARY"); + now = (uint32_t)time(NULL); portable_mutex_unlock(&myinfo->basilisk_mutex); if ( myinfo->NOTARY.RELAYID >= 0 ) { @@ -883,13 +884,13 @@ void basilisks_loop(void *arg) { //printf(">>>>>>>>>>>>> update %s\n",coin->symbol); basilisk_unspents_update(myinfo,coin); - coin->lastunspentsupdate = (uint32_t)time(NULL); + coin->lastunspentsupdate = now; //printf(">>>>>>>>>>>>> update %s finished\n",coin->symbol); } } - basilisk_requests_poll(myinfo); + if ( myinfo->IAMLP != 0 || myinfo->DEXactive > now ) + basilisk_requests_poll(myinfo); } - now = (uint32_t)time(NULL); portable_mutex_lock(&myinfo->messagemutex); HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg) { diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index 20b35162d..7689b7b09 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -373,41 +373,6 @@ char *basilisk_respond_accept(struct supernet_info *myinfo,uint32_t requestid,ui return(retstr); } -// respond to incoming RID, ACC, DEX, QST - -/*char *basilisk_respond_RID(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) -{ - return(basilisk_respond_requests(myinfo,hash,juint(valsobj,"requestid"),0)); -} - -char *basilisk_respond_SWP(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) -{ -return(basilisk_respond_swapstatus(myinfo,hash,juint(valsobj,"requestid"),juint(valsobj,"quoteid"))); -} - -char *basilisk_respond_ACC(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) -{ - uint32_t requestid,quoteid; - if ( (requestid= juint(valsobj,"requestid")) != 0 && (quoteid= juint(valsobj,"quoteid")) != 0 ) - return(basilisk_respond_accept(myinfo,requestid,quoteid)); - else return(clonestr("{\"error\":\"need nonzero requestid and quoteid\"}")); -} - -char *basilisk_respond_DEX(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) -{ - char *retstr=0,buf[256]; struct basilisk_request R; - if ( basilisk_request_create(&R,valsobj,hash,juint(valsobj,"timestamp")) == 0 ) - { - char str[65]; printf("DEX.(%s %.8f) -> %s %s\n",R.src,dstr(R.srcamount),R.dest,bits256_str(str,hash)); - if ( basilisk_request_enqueue(myinfo,&R) != 0 ) - { - sprintf(buf,"{\"result\":\"DEX request added\",\"requestid\":%u}",R.requestid); - retstr = clonestr(buf); - } else retstr = clonestr("{\"error\":\"DEX quote couldnt be created\"}"); - } else retstr = clonestr("{\"error\":\"missing or invalid fields\"}"); - return(retstr); -}*/ - #include "../includes/iguana_apidefs.h" #include "../includes/iguana_apideclares.h" @@ -457,7 +422,7 @@ STRING_ARG(InstantDEX,available,source) HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) { uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel; - myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME; + myinfo->DEXactive = (uint32_t)time(NULL) + BASILISK_TIMEOUT; jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN); if ( jobj(vals,"desthash") == 0 ) jaddbits256(vals,"desthash",hash); @@ -522,13 +487,12 @@ INT_ARG(InstantDEX,incoming,requestid) else if ( width > 64 ) width = 64; myinfo->DEXpoll = now; - myinfo->DEXactive = now + INSTANTDEX_LOCKTIME; retjson = cJSON_CreateObject(); DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16); msgid = (uint32_t)time(NULL) + drift; if ( (retarray= basilisk_channelget(myinfo,myinfo->myaddr.persistent,DEX_channel,msgid,width)) != 0 ) { - printf("GOT.(%s)\n",jprint(retarray,0)); + //printf("GOT.(%s)\n",jprint(retarray,0)); if ( (retval= basilisk_process_retarray(myinfo,0,InstantDEX_process_channelget,data,sizeof(data),DEX_channel,msgid,retarray,InstantDEX_incoming_func)) > 0 ) { jaddstr(retjson,"result","success"); diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index 40f255335..f8ee0ffab 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -111,9 +111,6 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_ for (i=0; i 0 ) @@ -121,12 +118,18 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_ if ( bits256_nonz(srchash) != 0 ) { keylen = basilisk_messagekey(key,channel,msgid,zero,desthash); + int32_t j; for (j=0; jDEXactive = expiration; while ( time(NULL) < expiration ) { printf("A r%u/q%u swapstate.%x\n",swap->req.requestid,swap->req.quoteid,swap->statebits); @@ -1123,6 +1124,7 @@ void basilisk_swaploop(void *_swap) } if ( time(NULL) >= expiration ) retval = -1; + myinfo->DEXactive = swap->expiration; printf("C r%u/q%u swapstate.%x\n",swap->req.requestid,swap->req.quoteid,swap->statebits); if ( retval == 0 && (swap->statebits & 0x40) == 0 ) // send fee { diff --git a/deprecated/obsolete.h b/deprecated/obsolete.h index 919eed598..2859d8b13 100755 --- a/deprecated/obsolete.h +++ b/deprecated/obsolete.h @@ -19152,5 +19152,40 @@ len = 0; //s->hdrsi = hdrsi; //s->bundlei = bundlei; //char str[65]; printf("%s set prevout.%d -> %d\n",bits256_str(str,prev_hash),prev_vout,s->prevout); + //if ( pkind != 0 ) // s->prevspendind = A[pkind].lastspendind; + // respond to incoming RID, ACC, DEX, QST + + /*char *basilisk_respond_RID(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) + { + return(basilisk_respond_requests(myinfo,hash,juint(valsobj,"requestid"),0)); + } + + char *basilisk_respond_SWP(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) + { + return(basilisk_respond_swapstatus(myinfo,hash,juint(valsobj,"requestid"),juint(valsobj,"quoteid"))); + } + + char *basilisk_respond_ACC(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) + { + uint32_t requestid,quoteid; + if ( (requestid= juint(valsobj,"requestid")) != 0 && (quoteid= juint(valsobj,"quoteid")) != 0 ) + return(basilisk_respond_accept(myinfo,requestid,quoteid)); + else return(clonestr("{\"error\":\"need nonzero requestid and quoteid\"}")); + } + + char *basilisk_respond_DEX(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) + { + char *retstr=0,buf[256]; struct basilisk_request R; + if ( basilisk_request_create(&R,valsobj,hash,juint(valsobj,"timestamp")) == 0 ) + { + char str[65]; printf("DEX.(%s %.8f) -> %s %s\n",R.src,dstr(R.srcamount),R.dest,bits256_str(str,hash)); + if ( basilisk_request_enqueue(myinfo,&R) != 0 ) + { + sprintf(buf,"{\"result\":\"DEX request added\",\"requestid\":%u}",R.requestid); + retstr = clonestr(buf); + } else retstr = clonestr("{\"error\":\"DEX quote couldnt be created\"}"); + } else retstr = clonestr("{\"error\":\"missing or invalid fields\"}"); + return(retstr); + }*/