Browse Source

Test

etomic
jl777 8 years ago
parent
commit
cdafac58be
  1. 6
      basilisk/basilisk.c
  2. 8
      basilisk/basilisk_DEX.c
  3. 31
      basilisk/basilisk_swap.c
  4. 4
      basilisk/jumblr.c
  5. 2
      iguana/dpow/dpow_network.c
  6. 2
      includes/iguana_funcs.h

6
basilisk/basilisk.c

@ -921,7 +921,7 @@ int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad)
void basilisks_loop(void *arg)
{
static uint32_t counter;
struct iguana_info *relay; struct supernet_info *myinfo = arg; int32_t iter; double startmilli,endmilli; struct dpow_info *dp;
struct iguana_info *relay; struct supernet_info *myinfo = arg; int32_t i,iter; double startmilli,endmilli; struct dpow_info *dp;
iter = 0;
relay = iguana_coinfind("RELAY");
printf("start basilisk loop\n");
@ -974,7 +974,9 @@ void basilisks_loop(void *arg)
if ( myinfo->expiration != 0 && (myinfo->dexsock >= 0 || myinfo->IAMLP != 0 || myinfo->DEXactive > time(NULL)) )
{
//fprintf(stderr,"H ");
basilisk_requests_poll(myinfo);
for (i=0; i<100; i++)
if ( basilisk_requests_poll(myinfo) <= 0 )
break;
}
//printf("RELAYID.%d endmilli %f vs now %f\n",myinfo->NOTARY.RELAYID,endmilli,startmilli);
while ( OS_milliseconds() < endmilli )

8
basilisk/basilisk_DEX.c

@ -281,12 +281,12 @@ char *basilisk_start(struct supernet_info *myinfo,bits256 privkey,struct basilis
} else return(clonestr("{\"error\":\"unexpected basilisk_start not mine and amrelay\"}"));
}
void basilisk_requests_poll(struct supernet_info *myinfo)
int32_t basilisk_requests_poll(struct supernet_info *myinfo)
{
static uint32_t lastpoll;
char *retstr; uint8_t data[32768]; cJSON *outerarray,*retjson; uint32_t msgid,channel; int32_t datalen,i,n; struct basilisk_request issueR; bits256 privkey; double hwm = 0.;
char *retstr; uint8_t data[32768]; cJSON *outerarray,*retjson; uint32_t msgid,channel; int32_t datalen,i,n,retval = 0; struct basilisk_request issueR; bits256 privkey; double hwm = 0.;
if ( myinfo->IAMNOTARY != 0 || time(NULL) < lastpoll+20 || (myinfo->IAMLP == 0 && myinfo->DEXactive < time(NULL)) )
return;
return(retval);
lastpoll = (uint32_t)time(NULL);
memset(&issueR,0,sizeof(issueR));
memset(&myinfo->DEXaccept,0,sizeof(myinfo->DEXaccept));
@ -298,6 +298,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
{
if ( (outerarray= jarray(&n,retjson,"responses")) != 0 )
{
retval++;
for (i=0; i<n; i++)
hwm = basilisk_process_results(myinfo,&issueR,jitem(outerarray,i),hwm);
} //else hwm = basilisk_process_results(myinfo,&issueR,outerarray,hwm);
@ -332,6 +333,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
free(retstr);
} //else printf("basilisk_requests_poll unexpected hwm issueR\n");
}
return(retval);
}
struct basilisk_relay *basilisk_request_ensure(struct supernet_info *myinfo,uint32_t senderipbits,int32_t numrequests)

31
basilisk/basilisk_swap.c

@ -1392,10 +1392,10 @@ int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap
if ( swap->I.iambob == 0 && swap->lasttime != 0 && time(NULL) > swap->lasttime+360 )
{
printf("nothing received for a while from Bob, try new sockets\n");
if ( swap->pushsock >= 0 )
nn_close(swap->pushsock), swap->pushsock = -1;
if ( swap->subsock >= 0 )
nn_close(swap->subsock), swap->subsock = -1;
if ( swap->pushsock >= 0 ) //nn_close(swap->pushsock),
swap->pushsock = -1;
if ( swap->subsock >= 0 ) //nn_close(swap->subsock),
swap->subsock = -1;
swap->connected = 0;
basilisk_psockinit(myinfo,swap,swap->I.iambob != 0);
}
@ -1429,9 +1429,9 @@ uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *sw
if ( sentbytes < 0 )
{
if ( swap->pushsock >= 0 )
nn_close(swap->pushsock), swap->pushsock = -1;
if ( swap->subsock >= 0 )
nn_close(swap->subsock), swap->subsock = -1;
swap->pushsock = -1; //nn_close(swap->pushsock),
if ( swap->subsock >= 0 ) // nn_close(swap->subsock),
swap->subsock = -1;
swap->connected = swap->I.iambob != 0 ? -1 : 0;
swap->aborted = (uint32_t)time(NULL);
}
@ -1451,10 +1451,10 @@ void basilisk_swap_sendabort(struct supernet_info *myinfo,struct basilisk_swap *
{
if ( sentbytes < 0 )
{
if ( swap->pushsock >= 0 )
nn_close(swap->pushsock), swap->pushsock = -1;
if ( swap->subsock >= 0 )
nn_close(swap->subsock), swap->subsock = -1;
if ( swap->pushsock >= 0 ) //nn_close(swap->pushsock),
swap->pushsock = -1;
if ( swap->subsock >= 0 ) //nn_close(swap->subsock),
swap->subsock = -1;
swap->connected = 0;
}
} else printf("basilisk_swap_sendabort\n");
@ -3261,6 +3261,8 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t
}
free(fstr);
}
if ( iambob < 0 )
return(0);
item = cJSON_CreateObject();
array = cJSON_CreateArray();
//printf("R.%u Q.%u\n",requestid,quoteid);
@ -3626,7 +3628,7 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t
char *basilisk_swaplist(struct supernet_info *myinfo)
{
char fname[512]; FILE *fp; cJSON *retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16]; int32_t i;
char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16]; int32_t i;
memset(KMDtotals,0,sizeof(KMDtotals));
memset(BTCtotals,0,sizeof(BTCtotals));
//,statebits; int32_t optionduration; struct basilisk_request R; bits256 privkey;
@ -3647,7 +3649,10 @@ char *basilisk_swaplist(struct supernet_info *myinfo)
break;
}
if ( flag == 0 )
jaddi(array,basilisk_remember(myinfo,KMDtotals,BTCtotals,requestid,quoteid));
{
if ( (item= basilisk_remember(myinfo,KMDtotals,BTCtotals,requestid,quoteid)) != 0 )
jaddi(array,item);
}
}
fclose(fp);
}

4
basilisk/jumblr.c

@ -753,7 +753,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32
jaddstr(vals,"source","BTC");
jaddstr(vals,"dest","KMD");
jaddnum(vals,"amount",vol);
jaddnum(vals,"minprice",1./kmdcoin->DEXinfo.btcprice);
jaddnum(vals,"minprice",0.985/kmdcoin->DEXinfo.btcprice);
jaddnum(vals,"usejumblr",1);
jaddnum(vals,"DEXselector",1);
memset(hash.bytes,0,sizeof(hash));
@ -786,7 +786,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32
jaddstr(vals,"dest","BTC");
jaddnum(vals,"amount",vol);
//jaddnum(vals,"destamount",JUMBLR_INCR*kmdcoin->DEXinfo.btcprice);
jaddnum(vals,"minprice",kmdcoin->DEXinfo.btcprice);
jaddnum(vals,"minprice",0.985 * kmdcoin->DEXinfo.btcprice);
jaddnum(vals,"usejumblr",2);
memset(hash.bytes,0,sizeof(hash));
kmdcoin->DEXinfo.KMDpending += vol;

2
iguana/dpow/dpow_network.c

@ -1263,7 +1263,7 @@ int32_t dex_packetcheck(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp
int32_t dex_subsock_poll(struct supernet_info *myinfo)
{
int32_t size= -1; struct dex_nanomsghdr *dexp; void *freeptr;
return(0);
//return(0);
//fprintf(stderr,"subsock.%d\n",myinfo->subsock);
if ( myinfo->subsock >= 0 && (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->subsock,&dexp)) >= 0 )
{

2
includes/iguana_funcs.h

@ -604,7 +604,7 @@ int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fil
void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits);
void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
void basilisk_requests_poll(struct supernet_info *myinfo);
int32_t basilisk_requests_poll(struct supernet_info *myinfo);
void dpow_psockloop(void *_ptr);
int32_t smartaddress_add(struct supernet_info *myinfo,bits256 privkey,char *BTCaddr,char *KMDaddr);
int32_t smartaddress(struct supernet_info *myinfo,bits256 *privkeyp,char *coinaddr);

Loading…
Cancel
Save