From ea468bab7f89b7df42c4e00a6df576495d8abf89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 13 Nov 2017 15:19:35 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_ordermatch.c | 21 ++++++++++++++------- iguana/exchanges/LP_socket.c | 2 ++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index b23ba015f..c7eeca62e 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -96,7 +96,7 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping #define JUMBLR_RMD160 "5177f8b427e5f47342a4b8ab5dac770815d4389e" #define TIERNOLAN_RMD160 "daedddd8dbe7a2439841ced40ba9c3d375f98146" #define INSTANTDEX_BTC "1KRhTPvoxyJmVALwHFXZdeeWFbcJSbkFPu" -#define INSTANTDEX_BTCD "RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf" +#define INSTANTDEX_KMD "RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf" //#define BASILISK_DISABLEWAITTX //#define BASILISK_DISABLESENDTX diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index d6b929b84..57e8d451b 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -21,11 +21,12 @@ struct LP_quoteinfo LP_Alicequery; double LP_Alicemaxprice; uint32_t Alice_expiration; -struct { uint64_t aliceid; double bestprice; uint32_t starttime; } Bob_competition[512]; +struct { uint64_t aliceid; double bestprice; uint32_t starttime,counter; } Bob_competition[512]; -double LP_bob_competition(uint64_t aliceid,double price) +double LP_bob_competition(int32_t *counterp,uint64_t aliceid,double price,int32_t counter) { int32_t i,firsti = -1; uint32_t now = (uint32_t)time(NULL); + *counterp = 0; for (i=0; i bestprice %.8f\n",(long long)aliceid,qprice,bestprice); if ( LP_Alicemaxprice == 0. ) return(retval); @@ -744,6 +750,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, } else if ( strcmp(method,"connected") == 0 ) { + bestprice = LP_bob_competition(&counter,aliceid,qprice,1000); if ( bits256_cmp(G.LP_mypub25519,Q.desthash) == 0 && bits256_cmp(G.LP_mypub25519,Q.srchash) != 0 ) { if ( (qprice= LP_quote_validate(autxo,butxo,&Q,0)) <= SMALLVAL ) @@ -833,10 +840,10 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, { r = (rand() % 100); range = (qprice - price); - printf(">>>>>>>>>>>>> price %.8f qprice %.8f r.%d range %.8f -> %.8f\n",price,qprice,r,range,price + (r*range)/100.); price += (r * range) / 100.; - bestprice = LP_bob_competition(aliceid,price); - if ( price < bestprice+SMALLVAL ) + bestprice = LP_bob_competition(&counter,aliceid,price,0); + printf(">>>>>>>>>>>>> price %.8f qprice %.8f r.%d range %.8f -> %.8f, bestprice %.8f counter.%d\n",ask,qprice,r,range,price,bestprice,counter); + if ( counter > 2 || price > bestprice*1.1 ) return(retval); } else return(retval); //printf("recalc.%d address.(%s/%s) price %.8f request.(%s)\n",recalc,Q.coinaddr,coin->smartaddr,price,jprint(argjson,0)); diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index e679ef67f..8d8cbb908 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -578,6 +578,8 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON cJSON *retjson=0; char *retstr; struct LP_address *ap; struct iguana_info *coin; int32_t updatedflag,height,usecache=1; if ( (coin= LP_coinfind(symbol)) == 0 ) return(0); + if ( strcmp(addr,INSTANTDEX_KMD) == 0 ) + return(cJSON_Parse("[]")); if ( ep == 0 || ep->heightp == 0 ) height = coin->longestchain; else height = *(ep->heightp);