Browse Source

test

etomic
jl777 8 years ago
parent
commit
0982974ea3
  1. 20
      basilisk/basilisk_DEX.c
  2. 7
      basilisk/basilisk_MSG.c
  3. 6
      basilisk/basilisk_swap.c
  4. 4
      iguana/dpow/dpow_network.c

20
basilisk/basilisk_DEX.c

@ -231,8 +231,16 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *_rp,uint32_t statebits,int32_t optionduration)
{
cJSON *retjson; struct basilisk_request *rp;
cJSON *retjson; struct basilisk_request *rp=0; int32_t i;
if ( (bits256_cmp(_rp->srchash,myinfo->myaddr.persistent) == 0 || bits256_cmp(_rp->desthash,myinfo->myaddr.persistent) == 0) )
{
for (i=0; i<myinfo->numswaps; i++)
if ( myinfo->swaps[i]->I.req.requestid == _rp->requestid )
{
printf("basilisk_thread_start error trying to start requestid.%u which is already started\n",rp->requestid);
break;
}
if ( i == myinfo->numswaps )
{
rp = calloc(1,sizeof(*rp));
*rp = *_rp;
@ -244,6 +252,12 @@ char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *_rp,u
}
else return(clonestr("{\"error\":\"couldnt atomic swap thread\"}"));
}
else
{
printf("trying to start already pending swap.r%u\n",rp->requestid);
return(clonestr("{\"error\":\"cant start pending swap\"}"));
}
}
else if ( myinfo->IAMLP != 0 )
{
retjson = cJSON_CreateObject();
@ -296,7 +310,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
free(retstr);
printf("my req hwm %f -> %u\n",hwm,issueR.requestid);
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters = 0;
numiters = crc = 0;
/*while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 )
{
printf("didnt get back what was sent\n");
@ -306,7 +320,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
}
if ( crc != 0 )*/
{
//printf("crc.%08x -> basilisk_starta\n",crc);
printf("crc.%08x -> basilisk_starta\n",crc);
if ( (retstr= basilisk_start(myinfo,&issueR,1,issueR.optionhours * 3600)) != 0 )
free(retstr);
} // else printf("couldnt accept offer\n");

7
basilisk/basilisk_MSG.c

@ -329,15 +329,16 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 srchash,bits25
jaddnum(valsobj,"channel",channel);
if ( msgid == 0 )
msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+2));
jaddnum(valsobj,"fanout",1);//MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+2));
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration);
jaddnum(valsobj,"timeout",1000);
jaddbits256(valsobj,"srchash",srchash);
jaddbits256(valsobj,"desthash",desthash);
//char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS);
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS);
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,desthash,valsobj,hexstr)) != 0 )
free(retstr);
printf("message sent\n");
free_json(valsobj);
if ( ptr != 0 )
free(ptr);
@ -380,7 +381,7 @@ cJSON *basilisk_channelget(struct supernet_info *myinfo,bits256 srchash,bits256
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"width",width);
jaddnum(valsobj,"timeout",BASILISK_TIMEOUT);
jaddnum(valsobj,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
jaddnum(valsobj,"fanout",1);//MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
jaddnum(valsobj,"numrequired",1);
jaddbits256(valsobj,"srchash",srchash);
jaddbits256(valsobj,"desthash",desthash);

6
basilisk/basilisk_swap.c

@ -1874,7 +1874,7 @@ struct basilisk_swap *basilisk_thread_start(struct supernet_info *myinfo,struct
}
if ( i == myinfo->numswaps && i < sizeof(myinfo->swaps)/sizeof(*myinfo->swaps) )
{
printf("basilisk_thread_start request.%u\n",rp->requestid);
printf("basilisk_thread_start request.%u statebits.%d\n",rp->requestid,statebits);
swap = calloc(1,sizeof(*swap));
vcalc_sha256(0,swap->I.orderhash.bytes,(uint8_t *)rp,sizeof(*rp));
swap->I.req = *rp;
@ -1909,7 +1909,7 @@ struct basilisk_swap *basilisk_thread_start(struct supernet_info *myinfo,struct
}
} else printf("no retarray\n");
}
if ( statebits != 0 || m > n/2 )
if ( statebits != 0 || m > 0 )//n/2 )
{
//for (i=0; i<sizeof(swap->I.req); i++)
// fprintf(stderr,"%02x",((uint8_t *)&swap->I.req)[i]);
@ -1919,7 +1919,7 @@ struct basilisk_swap *basilisk_thread_start(struct supernet_info *myinfo,struct
}
myinfo->swaps[myinfo->numswaps++] = swap;
} else printf("%u/%u offer wasnt accepted\n",rp->requestid,rp->quoteid);
} else printf("%u/%u offer wasnt accepted statebits.%d m.%d n.%d\n",rp->requestid,rp->quoteid,statebits,m,n);
}
}
portable_mutex_unlock(&myinfo->DEX_swapmutex);

4
iguana/dpow/dpow_network.c

@ -355,7 +355,7 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int3
// printf("%02x",((uint8_t *)data)[i]);
if ( (recvbytes= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->reqsock,&retptr)) >= 0 )
{
//printf("req returned.[%d]\n",recvbytes);
printf("req returned.[%d]\n",recvbytes);
portable_mutex_lock(&myinfo->dexmutex);
ipbits = 0;
if ( strcmp(handler,"DEX") == 0 )
@ -394,7 +394,7 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int3
printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str);
}
}
if ( (rand() % 100) < 4 )
if ( (rand() % 100) < 0 )
{
nanomsg_tcpname(0,str,ipaddr,REP_SOCK);
nn_connect(myinfo->reqsock,str);

Loading…
Cancel
Save