From c6b3ff8a5aa3f7bcef9d6b22b1d3f131894a1dde Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 10:51:43 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 2 +- basilisk/basilisk.h | 2 ++ basilisk/basilisk_DEX.c | 20 ++++++++++++-------- basilisk/basilisk_tradebot.c | 36 +++++++++++++++++++++++++----------- includes/iguana_structs.h | 2 +- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 92e59900e..dba265ba6 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -806,7 +806,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) memset(&issueR,0,sizeof(issueR)); if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 ) { - printf("poll.(%s)\n",retstr); + //printf("poll.(%s)\n",retstr); if ( (retjson= cJSON_Parse(retstr)) != 0 ) { if ( (outerarray= jarray(&n,retjson,"responses")) != 0 ) diff --git a/basilisk/basilisk.h b/basilisk/basilisk.h index efadbc0fc..2f3183160 100755 --- a/basilisk/basilisk.h +++ b/basilisk/basilisk.h @@ -120,5 +120,7 @@ struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbo void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn); void basilisk_rawtx_setparms(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,struct iguana_info *coin,int32_t numconfirms,int32_t vintype,uint64_t satoshis,int32_t vouttype,uint8_t *pubkey33); void basilisk_setmyid(struct supernet_info *myinfo); +int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_request *rp); +cJSON *basilisk_requestjson(struct basilisk_request *rp); #endif diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index f8445e521..1e0e546af 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -100,7 +100,7 @@ int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_r len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->timestamp),&rp->timestamp); // must be 2nd len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->quoteid),&rp->quoteid); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->quotetime),&rp->quotetime); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits); + //len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->srcamount),&rp->srcamount); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->minamount),&rp->minamount); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->srchash),rp->srchash.bytes); @@ -142,12 +142,12 @@ uint32_t basilisk_request_enqueue(struct supernet_info *myinfo,struct basilisk_r cJSON *basilisk_requestjson(struct basilisk_request *rp) { - char ipaddr[64]; cJSON *item = cJSON_CreateObject(); - if ( rp->relaybits != 0 ) + cJSON *item = cJSON_CreateObject(); + /*if ( rp->relaybits != 0 ) { expand_ipbits(ipaddr,rp->relaybits); jaddstr(item,"relay",ipaddr); - } + }*/ jaddbits256(item,"srchash",rp->srchash); if ( bits256_nonz(rp->desthash) != 0 ) jaddbits256(item,"desthash",rp->desthash); @@ -209,6 +209,8 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2 rp->srchash = jbits256(valsobj,"srchash"); strncpy(rp->src,src,sizeof(rp->src)-1); strncpy(rp->dest,dest,sizeof(rp->dest)-1); + //if ( jstr(valsobj,"relay") != 0 ) + // rp->relaybits = (uint32_t)calc_ipbits(jstr(valsobj,"relay")); rp->requestid = basilisk_requestid(rp); if ( rp->destamount != 0 && bits256_nonz(rp->desthash) != 0 ) { @@ -302,7 +304,7 @@ struct basilisk_request *_basilisk_requests_uniq(struct supernet_info *myinfo,in break; if ( k == m ) { - requests[m].relaybits = relay->ipbits; + //requests[m].relaybits = relay->ipbits; requests[m++] = *rp; } } @@ -438,12 +440,14 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) if ( basilisk_request_create(&R,vals,hash,juint(vals,"timestamp")) == 0 ) { printf("R.requestid.%u vs calc %u, q.%u\n",R.requestid,basilisk_requestid(&R),R.quoteid); - if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) - R.relaybits = myinfo->myaddr.myipbits; + //if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) + // R.relaybits = myinfo->myaddr.myipbits; if ( (reqjson= basilisk_requestjson(&R)) != 0 ) free_json(reqjson); datalen = basilisk_rwDEXquote(1,serialized,&R); - printf("R.requestid.%u vs calc %u, q.%u datalen.%d\n",R.requestid,basilisk_requestid(&R),R.quoteid,datalen); + int32_t i; for (i=0; idestamount = j64bits(reqjson,"destamount"); requestid = juint(reqjson,"requestid"); quoteid = juint(reqjson,"quoteid"); - if ( jstr(reqjson,"relay") != 0 ) - rp->relaybits = (uint32_t)calc_ipbits(jstr(reqjson,"relay")); + //if ( jstr(reqjson,"relay") != 0 ) + // rp->relaybits = (uint32_t)calc_ipbits(jstr(reqjson,"relay")); rp->timestamp = juint(reqjson,"timestamp"); rp->quotetime = juint(reqjson,"quotetime"); safecopy(rp->src,jstr(reqjson,"src"),sizeof(rp->src)); @@ -67,7 +67,11 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r } rp->requestid = basilisk_requestid(rp); if ( requestid != rp->requestid ) - printf("basilisk_parsejson requestid.%u != %u error\n",requestid,rp->requestid); + { + int32_t i; for (i=0; irequestid); + } return(rp); } @@ -159,7 +163,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; uint64_t destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.; memset(issueR,0,sizeof(*issueR)); minamount = list[0].minamount; - printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); + //printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 ) pendingid = active->req.quoteid; if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request @@ -230,19 +234,26 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_request *issueR,cJSON *retjson,double hwm) { - cJSON *array,*item; int32_t i,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; + cJSON *array,*item; uint8_t *hexdata,*allocptr,hexspace[8192]; char *hexstr; int32_t i,hexlen,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; memset(&refR,0,sizeof(refR)); -printf("process.(%s)\n",jprint(retjson,0)); +//printf("process.(%s)\n",jprint(retjson,0)); if ( (array= jarray(&n,retjson,"messages")) != 0 ) { for (i=nonz=m=0; i