From 9dda18a3cc311b4a4ca880d3ef60fc4c3c4203f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 09:17:37 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 2 +- basilisk/basilisk_DEX.c | 16 +++++++++------- basilisk/basilisk_swap.c | 4 ++-- basilisk/basilisk_tradebot.c | 8 ++++---- includes/iguana_structs.h | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index c54a5fc0b..9786b8f56 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -820,7 +820,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) } else printf("null incoming\n"); if ( hwm > 0. ) { - if ( bits256_cmp(myinfo->myaddr.persistent,issueR.hash) == 0 ) // my request + if ( bits256_cmp(myinfo->myaddr.persistent,issueR.srchash) == 0 ) // my request { printf("my req hwm %f\n",hwm); if ( (retstr= InstantDEX_accept(myinfo,0,0,0,issueR.requestid,issueR.quoteid)) != 0 ) diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index c2d01b418..f8445e521 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -103,7 +103,7 @@ int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_r 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->hash),rp->hash.bytes); + len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->srchash),rp->srchash.bytes); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->desthash),rp->desthash.bytes); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->destamount),&rp->destamount); if ( rwflag != 0 ) @@ -148,7 +148,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp) expand_ipbits(ipaddr,rp->relaybits); jaddstr(item,"relay",ipaddr); } - jaddbits256(item,"hash",rp->hash); + jaddbits256(item,"srchash",rp->srchash); if ( bits256_nonz(rp->desthash) != 0 ) jaddbits256(item,"desthash",rp->desthash); jaddstr(item,"src",rp->src); @@ -189,7 +189,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp) return(item); } -int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits256 hash,uint32_t timestamp) +int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits256 desthash,uint32_t timestamp) { char *dest,*src; uint32_t i; memset(rp,0,sizeof(*rp)); @@ -197,7 +197,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2 { if ( (rp->destamount= j64bits(valsobj,"destsatoshis")) != 0 ) { - rp->desthash = jbits256(valsobj,"desthash"); + rp->desthash = desthash; for (i=0; i<4; i++) if ( rp->desthash.ulongs[i] != 0 ) break; @@ -206,7 +206,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2 } rp->minamount = j64bits(valsobj,"minamount"); rp->timestamp = timestamp; - rp->hash = hash; + rp->srchash = jbits256(valsobj,"srchash"); strncpy(rp->src,src,sizeof(rp->src)-1); strncpy(rp->dest,dest,sizeof(rp->dest)-1); rp->requestid = basilisk_requestid(rp); @@ -224,7 +224,7 @@ 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) { cJSON *retjson; - if ( (bits256_cmp(rp->hash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) ) + if ( (bits256_cmp(rp->srchash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) ) { printf("START thread to complete %u/%u for (%s %.8f) <-> (%s %.8f) q.%u\n",rp->requestid,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount),rp->quoteid); if ( basilisk_thread_start(myinfo,rp) != 0 ) @@ -333,7 +333,7 @@ char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32 for (i=0; iquoteid && (bits256_cmp(hash,rp->hash) == 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; else qflag = 0; if ( requestid == 0 || (rp->requestid == requestid && qflag != 0) ) @@ -424,6 +424,8 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel; myinfo->DEXactive = (uint32_t)time(NULL) + BASILISK_TIMEOUT; jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN); + if ( jobj(vals,"srchash") == 0 ) + jaddbits256(vals,"srchash",myinfo->myaddr.pubkey); if ( jobj(vals,"desthash") == 0 ) jaddbits256(vals,"desthash",hash); jadd64bits(vals,"satoshis",jdouble(vals,"amount") * SATOSHIDEN); diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 78f8f516a..b2bb9c482 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -751,7 +751,7 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,struct basil swap->choosei %= INSTANTDEX_DECKSIZE; swap->otherchoosei = -1; swap->myhash = myinfo->myaddr.persistent; - if ( bits256_cmp(swap->myhash,swap->req.hash) == 0 ) + if ( bits256_cmp(swap->myhash,swap->req.srchash) == 0 ) { swap->otherhash = swap->req.desthash; if ( strcmp(swap->req.src,swap->bobstr) == 0 ) @@ -764,7 +764,7 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,struct basil } else if ( bits256_cmp(swap->myhash,swap->req.desthash) == 0 ) { - swap->otherhash = swap->req.hash; + swap->otherhash = swap->req.srchash; if ( strcmp(swap->req.dest,swap->bobstr) == 0 ) swap->iambob = 1; else if ( strcmp(swap->req.src,swap->alicestr) != 0 ) diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 2656fc468..846188ea2 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -29,7 +29,7 @@ uint32_t basilisk_requestid(struct basilisk_request *rp) for (i=0; i %s %.8f %s crc.%u\n",R.timestamp,R.requestid,R.quoteid,R.src,dstr(R.srcamount),bits256_str(str,R.hash),R.dest,dstr(R.destamount),bits256_str(str2,R.desthash),calc_crc32(0,(void *)&R,sizeof(R))); + char str[65],str2[65]; printf("B REQUESTID: t.%u r.%u q.%u %s %.8f %s -> %s %.8f %s crc.%u\n",R.timestamp,R.requestid,R.quoteid,R.src,dstr(R.srcamount),bits256_str(str,R.srchash),R.dest,dstr(R.destamount),bits256_str(str2,R.desthash),calc_crc32(0,(void *)&R,sizeof(R))); } return(calc_crc32(0,(void *)&R,sizeof(R))); } @@ -46,7 +46,7 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r { uint32_t requestid,quoteid; memset(rp,0,sizeof(*rp)); - rp->hash = jbits256(reqjson,"hash"); + rp->srchash = jbits256(reqjson,"srchash"); rp->desthash = jbits256(reqjson,"desthash"); rp->srcamount = j64bits(reqjson,"srcamount"); rp->minamount = j64bits(reqjson,"minamount"); @@ -102,7 +102,7 @@ struct basilisk_swap *basilisk_request_started(struct supernet_info *myinfo,uint int32_t basilisk_request_cmpref(struct basilisk_request *ref,struct basilisk_request *rp) { - if ( bits256_cmp(rp->hash,ref->hash) != 0 || memcmp(rp->src,ref->src,sizeof(ref->src)) != 0 || memcmp(rp->dest,ref->dest,sizeof(ref->dest)) != 0 || rp->srcamount != ref->srcamount || rp->timestamp != ref->timestamp ) + if ( bits256_cmp(rp->srchash,ref->srchash) != 0 || memcmp(rp->src,ref->src,sizeof(ref->src)) != 0 || memcmp(rp->dest,ref->dest,sizeof(ref->dest)) != 0 || rp->srcamount != ref->srcamount || rp->timestamp != ref->timestamp ) { printf("basilisk_request_listprocess mismatched hash\n"); return(-1); @@ -162,7 +162,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk 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].hash) == 0 ) // my request + if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request myrequest = 1; for (i=0; i