From 0e5fbf2a75bcef33ed73f48e63cb7c02344a30c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 5 Mar 2017 19:14:58 +0200 Subject: [PATCH] Test --- basilisk/basilisk_swap.c | 64 ++---------------------------------- basilisk/basilisk_tradebot.c | 2 +- 2 files changed, 3 insertions(+), 63 deletions(-) diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index e2885b51f..e015ff4a4 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -885,9 +885,6 @@ void basilisk_swapgotdata(struct supernet_info *myinfo,struct basilisk_swap *swa for (i=0; inummessages; i++) if ( crc32 == swap->messages[i].crc32 ) return; - if ( datalen < 8 ) - for (i=0; inummessages,datalen,quoteid,msgbits); swap->messages = realloc(swap->messages,sizeof(*swap->messages) * (swap->nummessages + 1)); mp = &swap->messages[swap->nummessages++]; @@ -904,42 +901,6 @@ void basilisk_swapgotdata(struct supernet_info *myinfo,struct basilisk_swap *swa int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,int32_t (*basilisk_verify_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)) { uint8_t *ptr; bits256 srchash,desthash; uint32_t crc32,_msgbits,quoteid; int32_t i,size,offset,retval = -1; - /*cJSON *valsobj,*array,*item; int32_t i,n,datalen,retval = -1; char *retstr,*hexstr=0; - //int32_t datalen; uint32_t crc; - //if ( (crc= basilisk_crcrecv(myinfo,0,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 ) - valsobj = cJSON_CreateObject(); - jaddnum(valsobj,"channel",swap->I.req.quoteid); - jaddnum(valsobj,"msgid",msgbits); - jaddbits256(valsobj,"srchash",swap->I.otherhash); - jaddbits256(valsobj,"desthash",swap->I.myhash); - jaddnum(valsobj,"width",30); - if ( (retstr= _dex_getmessage(myinfo,jprint(valsobj,1))) != 0 ) - { - if ( (array= cJSON_Parse(retstr)) != 0 ) - { - if ( (n= cJSON_GetArraySize(array)) > 0 ) - { - for (i=0; i> 1; - if ( datalen > 0 && datalen < maxlen ) - { - decode_hex(data,datalen,hexstr); - if ( (retval= (*basilisk_verify_func)(myinfo,swap,data,datalen)) == 0 ) - { - break; - } - } - } - } - } - free_json(array); - } - free(retstr); - }*/ while ( (size= nn_recv(swap->subsock,&ptr,NN_MSG,0)) >= 0 ) { memset(srchash.bytes,0,sizeof(srchash)); @@ -952,12 +913,6 @@ int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap desthash.bytes[i] = ptr[offset++]; offset += iguana_rwnum(0,&ptr[offset],sizeof(uint32_t),"eid); offset += iguana_rwnum(0,&ptr[offset],sizeof(uint32_t),&_msgbits); - if ( _msgbits == 0x80000000 ) - { - for (i=0; i offset ) basilisk_swapgotdata(myinfo,swap,crc32,srchash,desthash,quoteid,_msgbits,&ptr[offset],size-offset); if ( ptr != 0 ) @@ -967,12 +922,6 @@ int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap { if ( swap->messages[i].msgbits == msgbits && bits256_cmp(swap->messages[i].desthash,swap->persistent_pubkey) == 0 ) { - if ( swap->messages[i].datalen < 8 ) - { - for (i=0; imessages[i].datalen; i++) - printf("%02x",swap->messages[i].data[i]); - printf("matched %x datalen.%d\n",msgbits,swap->messages[i].datalen); - } retval = (*basilisk_verify_func)(myinfo,swap,swap->messages[i].data,swap->messages[i].datalen); break; } @@ -999,15 +948,6 @@ uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *sw memcpy(&buf[offset],data,datalen), offset += datalen; if ( (sentbytes= nn_send(swap->pushsock,buf,offset,0)) != offset ) printf("sentbytes.%d vs offset.%d\n",sentbytes,offset); - else - { - if ( msgbits == 0x80000000 ) - { - for (i=0; i<4; i++) - printf("%02x ",data[i]); - printf("datalen.%d offset.%d\n",datalen,offset); - } - } free(buf); return(0); } @@ -1412,7 +1352,7 @@ int32_t basilisk_verify_otherstatebits(struct supernet_info *myinfo,void *ptr,ui if ( datalen == sizeof(swap->I.otherstatebits) ) { retval = iguana_rwnum(0,data,sizeof(swap->I.otherstatebits),&swap->I.otherstatebits); - printf("got sendstate.%x\n",swap->I.otherstatebits); + //printf("got sendstate.%x\n",swap->I.otherstatebits); return(retval); } else return(-1); } @@ -1568,7 +1508,7 @@ int32_t basilisk_checkdeck(struct supernet_info *myinfo,struct basilisk_swap *sw void basilisk_sendstate(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { int32_t datalen; - printf("sendstate.%x\n",swap->I.statebits); + //printf("sendstate.%x\n",swap->I.statebits); datalen = iguana_rwnum(1,data,sizeof(swap->I.statebits),&swap->I.statebits); basilisk_swapsend(myinfo,swap,0x80000000,data,datalen,0,0); } diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index dbb6ca742..ec60b1cc2 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -104,7 +104,7 @@ int32_t basilisk_swapconv(struct supernet_info *myinfo,struct basilisk_swap *swa if ( juint(obj,"requestid") == swap->I.req.requestid && juint(obj,"quoteid") == swap->I.req.quoteid ) return(0); printf("swapconv mismatched req/quote %d %d, %d %d\n",juint(obj,"requestid"),swap->I.req.requestid,juint(obj,"quoteid"),swap->I.req.quoteid); - } else printf("no info field in swap obj.(%s)\n",jprint(obj,0)); + } else printf("no info field in swap obj.(%s) len.%d vs %d\n",jprint(obj,0),(int32_t)strlen(hexstr),(int32_t)sizeof(swap->I)*2); return(-1); }