jl777 8 years ago
parent
commit
7a1a9373d0
  1. 7
      basilisk/basilisk.c
  2. 40
      basilisk/basilisk_DEX.c
  3. 9
      basilisk/basilisk_MSG.c
  4. 2
      basilisk/basilisk_swap.c
  5. 35
      deprecated/obsolete.h

7
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)
{

40
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");

9
basilisk/basilisk_MSG.c

@ -111,9 +111,6 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
for (i=0; i<width; i++)
{
keylen = basilisk_messagekey(key,channel,msgid,srchash,desthash);
int32_t j; for (j=0; j<keylen; j++)
printf("%02x",key[j]);
printf(" <- key\n");
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
if ( origwidth > 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; j<keylen; j++)
printf("%02x",key[j]);
printf(" <- key\n");
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
}
if ( bits256_nonz(desthash) != 0 )
{
keylen = basilisk_messagekey(key,channel,msgid,srchash,zero);
int32_t j; for (j=0; j<keylen; j++)
printf("%02x",key[j]);
printf(" <- key\n");
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
}

2
basilisk/basilisk_swap.c

@ -1098,6 +1098,7 @@ void basilisk_swaploop(void *_swap)
maxlen = 1024*1024 + sizeof(*swap);
data = malloc(maxlen);
expiration = (uint32_t)time(NULL) + 300;
myinfo->DEXactive = 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
{

35
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);
}*/

Loading…
Cancel
Save