Browse Source

test

etomic
jl777 8 years ago
parent
commit
259a369a9b
  1. 20
      basilisk/basilisk_DEX.c
  2. 2
      basilisk/basilisk_MSG.c
  3. 2
      iguana/dpow/dpow_fsm.c

20
basilisk/basilisk_DEX.c

@ -216,11 +216,11 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
//if ( jstr(valsobj,"relay") != 0 ) //if ( jstr(valsobj,"relay") != 0 )
// rp->relaybits = (uint32_t)calc_ipbits(jstr(valsobj,"relay")); // rp->relaybits = (uint32_t)calc_ipbits(jstr(valsobj,"relay"));
rp->requestid = basilisk_requestid(rp); rp->requestid = basilisk_requestid(rp);
printf("set requestid <- %u\n",rp->requestid); //printf("set requestid <- %u\n",rp->requestid);
if ( rp->destamount != 0 && bits256_nonz(rp->desthash) != 0 ) if ( rp->destamount != 0 && bits256_nonz(rp->desthash) != 0 )
{ {
rp->quoteid = basilisk_quoteid(rp); rp->quoteid = basilisk_quoteid(rp);
printf("set quoteid.%u\n",rp->quoteid); //printf("set quoteid.%u\n",rp->quoteid);
} }
//printf("create.%u calc.%u\n",rp->requestid,basilisk_requestid(rp)); //printf("create.%u calc.%u\n",rp->requestid,basilisk_requestid(rp));
return(0); return(0);
@ -252,7 +252,7 @@ char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *rp,ui
void basilisk_requests_poll(struct supernet_info *myinfo) void basilisk_requests_poll(struct supernet_info *myinfo)
{ {
static uint32_t lastpoll; static uint32_t lastpoll;
char *retstr; uint8_t data[32768],buf[4096]; cJSON *outerarray,*retjson; uint32_t msgid,crcs[2],crc,channel; int32_t datalen,i,n,numiters; struct basilisk_request issueR; double hwm = 0.; char *retstr; uint8_t data[32768],buf[4096],key[BASILISK_KEYSIZE]; cJSON *outerarray,*retjson; uint32_t msgid,crcs[2],crc,channel; int32_t datalen,i,n,keylen,numiters; struct basilisk_request issueR; double hwm = 0.;
if ( time(NULL) < lastpoll+3 ) if ( time(NULL) < lastpoll+3 )
return; return;
lastpoll = (uint32_t)time(NULL); lastpoll = (uint32_t)time(NULL);
@ -281,6 +281,12 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
printf("%02x",((uint8_t *)&issueR)[i]); printf("%02x",((uint8_t *)&issueR)[i]);
printf("\n"); printf("\n");
myinfo->DEXaccept = issueR; myinfo->DEXaccept = issueR;
issueR.quoteid = basilisk_quoteid(&issueR);
datalen = basilisk_rwDEXquote(1,data,&issueR);
msgid = (uint32_t)time(NULL);
keylen = basilisk_messagekey(key,0,msgid,issueR.srchash,issueR.desthash);
if ( (retstr= basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,0,BASILISK_DEXDURATION)) != 0 )
free(retstr);
if ( bits256_cmp(myinfo->myaddr.persistent,issueR.srchash) == 0 ) // my request if ( bits256_cmp(myinfo->myaddr.persistent,issueR.srchash) == 0 ) // my request
{ {
printf("my req hwm %f\n",hwm); printf("my req hwm %f\n",hwm);
@ -428,16 +434,15 @@ char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32
portable_mutex_lock(&myinfo->DEX_reqmutex); portable_mutex_lock(&myinfo->DEX_reqmutex);
if ( (requests= _basilisk_requests_uniq(myinfo,&num,space,sizeof(space),refrp)) != 0 ) if ( (requests= _basilisk_requests_uniq(myinfo,&num,space,sizeof(space),refrp)) != 0 )
{ {
printf("numrequests.%d r.%u q.%u\n",num,requestid,quoteid);
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
rp = &requests[i]; rp = &requests[i];
if ( quoteid == 0 || (quoteid == rp->quoteid && (bits256_cmp(hash,rp->srchash) == 0 || bits256_cmp(hash,rp->desthash) == 0)) ) if ( quoteid == 0 || (quoteid == rp->quoteid && (bits256_cmp(hash,rp->srchash) == 0 || bits256_cmp(hash,rp->desthash) == 0)) )
qflag = 1; qflag = 1;
else qflag = 0; else qflag = 0;
int32_t j; for (j=0; j<sizeof(*rp); j++) //int32_t j; for (j=0; j<sizeof(*rp); j++)
printf("%02x",((uint8_t *)rp)[j]); // printf("%02x",((uint8_t *)rp)[j]);
printf(" rp[%d] of %d qflag.%d\n",i,num,qflag); //printf(" rp[%d] of %d qflag.%d\n",i,num,qflag);
if ( requestid == 0 || (rp->requestid == requestid && qflag != 0) ) if ( requestid == 0 || (rp->requestid == requestid && qflag != 0) )
jaddi(array,basilisk_requestjson(rp)); jaddi(array,basilisk_requestjson(rp));
} }
@ -454,7 +459,6 @@ char *basilisk_respond_accept(struct supernet_info *myinfo,uint32_t requestid,ui
{ {
int32_t i,num=0; char *retstr=0; struct basilisk_request *requests,*rp; uint8_t space[4096]; int32_t i,num=0; char *retstr=0; struct basilisk_request *requests,*rp; uint8_t space[4096];
portable_mutex_lock(&myinfo->DEX_reqmutex); portable_mutex_lock(&myinfo->DEX_reqmutex);
printf("respond accept\n");
if ( (requests= _basilisk_requests_uniq(myinfo,&num,space,sizeof(space),refrp)) != 0 ) if ( (requests= _basilisk_requests_uniq(myinfo,&num,space,sizeof(space),refrp)) != 0 )
{ {
for (i=0; i<num; i++) for (i=0; i<num; i++)

2
basilisk/basilisk_MSG.c

@ -76,7 +76,7 @@ int32_t basilisk_msgcmp(struct basilisk_message *msg,int32_t width,uint32_t chan
{ {
while ( width >= 0 && n < 60 ) while ( width >= 0 && n < 60 )
{ {
if ( msgid == keymsgid && keychannel == channel ) if ( (keymsgid == 0 || msgid == keymsgid) && (keychannel == 0 || keychannel == channel) )
return(0); return(0);
msgid--; msgid--;
n++; n++;

2
iguana/dpow/dpow_fsm.c

@ -412,7 +412,7 @@ void dpow_statemachinestart(void *ptr)
extralen = dpow_paxpending(extras,&bp->paxwdcrc); extralen = dpow_paxpending(extras,&bp->paxwdcrc);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
} }
sleep(1); sleep(3);
if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height )
{ {
if ( bp->isratify == 0 ) if ( bp->isratify == 0 )

Loading…
Cancel
Save