|
|
@ -559,7 +559,7 @@ struct instantdex_accept *instantdex_acceptable(struct supernet_info *myinfo,str |
|
|
|
minvol = A->offer.basevolume64 * minperc * .01; |
|
|
|
while ( (ap= queue_dequeue(&exchange->acceptableQ,0)) != 0 && ap != &PAD ) |
|
|
|
{ |
|
|
|
printf("check offerbits.%llu vs %llu: %d %d %d %d %d %d %d %d\n",(long long)offerbits,(long long)ap->offer.offer64,A->offer.basevolume64 > 0.,strcmp(A->offer.base,"*") == 0 ,strcmp(A->offer.base,ap->offer.base) == 0, strcmp(A->offer.rel,"*") == 0 ,strcmp(A->offer.rel,ap->offer.rel) == 0,A->offer.basevolume64 <= (ap->offer.basevolume64 - ap->pendingvolume64),offerdir,instantdex_bidaskdir(ap)); |
|
|
|
//printf("check offerbits.%llu vs %llu: %d %d %d %d %d %d %d %d\n",(long long)offerbits,(long long)ap->offer.offer64,A->offer.basevolume64 > 0.,strcmp(A->offer.base,"*") == 0 ,strcmp(A->offer.base,ap->offer.base) == 0, strcmp(A->offer.rel,"*") == 0 ,strcmp(A->offer.rel,ap->offer.rel) == 0,A->offer.basevolume64 <= (ap->offer.basevolume64 - ap->pendingvolume64),offerdir,instantdex_bidaskdir(ap));
|
|
|
|
if ( now < ap->offer.expiration && ap->dead == 0 && (offerbits == 0 || offerbits != ap->offer.offer64) ) |
|
|
|
{ |
|
|
|
if ( A->offer.basevolume64 > 0. && (strcmp(A->offer.base,"*") == 0 || strcmp(A->offer.base,ap->offer.base) == 0) && (strcmp(A->offer.rel,"*") == 0 || strcmp(A->offer.rel,ap->offer.rel) == 0) && minvol <= (ap->offer.basevolume64 - ap->pendingvolume64) && offerdir*instantdex_bidaskdir(ap) < 0 ) |
|
|
@ -567,7 +567,7 @@ struct instantdex_accept *instantdex_acceptable(struct supernet_info *myinfo,str |
|
|
|
//printf("aveprice %.8f %.8f offerdir.%d first cmp: %d %d %d\n",aveprice,dstr(ap->offer.price64),offerdir,A->offer.price64 == 0,(offerdir > 0 && ap->offer.price64 >= A->offer.price64),(offerdir < 0 && ap->offer.price64 <= A->offer.price64));
|
|
|
|
if ( offerdir == 0 || A->offer.price64 == 0 || ((offerdir < 0 && ap->offer.price64 >= A->offer.price64) || (offerdir > 0 && ap->offer.price64 <= A->offer.price64)) ) |
|
|
|
{ |
|
|
|
printf("passed second cmp: offerdir.%d best %.8f ap %.8f\n",offerdir,dstr(bestprice64),dstr(ap->offer.price64)); |
|
|
|
//printf("passed second cmp: offerdir.%d best %.8f ap %.8f\n",offerdir,dstr(bestprice64),dstr(ap->offer.price64));
|
|
|
|
if ( bestprice64 == 0 || (offerdir < 0 && ap->offer.price64 < bestprice64) || (offerdir > 0 && ap->offer.price64 > bestprice64) ) |
|
|
|
{ |
|
|
|
printf("found better price %f vs %f\n",dstr(ap->offer.price64),dstr(bestprice64)); |
|
|
@ -693,6 +693,7 @@ char *instantdex_swapset(struct supernet_info *myinfo,struct instantdex_accept * |
|
|
|
insurance = (satoshis[1] * INSTANTDEX_INSURANCERATE + coinbtc->chain->txfee); // txfee prevents papercut attack
|
|
|
|
offerdir = instantdex_bidaskdir(ap); |
|
|
|
vcalc_sha256(0,orderhash.bytes,(void *)&ap->offer,sizeof(ap->offer)); |
|
|
|
if ( 0 ) |
|
|
|
{ |
|
|
|
int32_t i; |
|
|
|
for (i=0; i<sizeof(ap->offer); i++) |
|
|
@ -887,7 +888,7 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms |
|
|
|
{ |
|
|
|
if ( (retstr= instantdex_gotoffer(myinfo,exchange,ap,msg,argjson,remoteaddr,signerbits,serdata,serdatalen)) != 0 ) // adds to statemachine if no error
|
|
|
|
{ |
|
|
|
printf("from GOTOFFER\n"); |
|
|
|
//printf("from GOTOFFER\n");
|
|
|
|
return(instantdex_selectqueue(exchange,ap,retstr)); |
|
|
|
} |
|
|
|
} |
|
|
@ -969,7 +970,7 @@ char *InstantDEX_hexmsg(struct supernet_info *myinfo,void *ptr,int32_t len,char |
|
|
|
else if ( (signerbits= acct777_validate(&msg->sig,acct777_msgprivkey(serdata,datalen),msg->sig.pubkey)) != 0 || 1 ) |
|
|
|
{ |
|
|
|
flag++; |
|
|
|
//printf("InstantDEX_hexmsg <<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d t%u allocsize.%d (%s) [%d]\n",sizeof(msg->sig),(long)serdata-(long)msg,datalen,msg->sig.timestamp,msg->sig.allocsize,(char *)msg->serialized,serdata[datalen-1]);
|
|
|
|
printf("InstantDEX_hexmsg <<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d t%u allocsize.%d (%s) [%d]\n",sizeof(msg->sig),(long)serdata-(long)msg,datalen,msg->sig.timestamp,msg->sig.allocsize,(char *)msg->serialized,serdata[datalen-1]); |
|
|
|
newlen = (int32_t)(msg->sig.allocsize - ((long)msg->serialized - (long)msg)); |
|
|
|
serdata = msg->serialized; |
|
|
|
//printf("newlen.%d diff.%ld alloc.%d datalen.%d\n",newlen,((long)msg->serialized - (long)msg),msg->sig.allocsize,datalen);
|
|
|
|