From 26b73f73852b1b92e5b1ccb24d0ed50754aac19a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 2 Apr 2018 13:46:00 +0300 Subject: [PATCH] Fastflag --- iguana/exchanges/DEXstats.h | 2 +- iguana/exchanges/LP_commands.c | 10 +++++++++- iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/fasttest | 6 ++++++ iguana/exchanges/mm.c | 2 +- iguana/exchanges/stats.c | 14 +++++++------- 6 files changed, 26 insertions(+), 12 deletions(-) create mode 100755 iguana/exchanges/fasttest diff --git a/iguana/exchanges/DEXstats.h b/iguana/exchanges/DEXstats.h index dc1f89864..3758a4e55 100644 --- a/iguana/exchanges/DEXstats.h +++ b/iguana/exchanges/DEXstats.h @@ -928,7 +928,7 @@ char *stats_prices(char *symbol,char *dest,struct DEXstats_disp *prices,int32_t #ifndef FROM_MARKETMAKER #ifndef FROM_PRIVATEBET -char *stats_JSON(void *ctx,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port) +char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port) { char *method,*agent,*retstr,*source,*dest; struct tai T; uint32_t endtimestamp; struct DEXstats_disp prices[365]; int32_t leftdatenum,seconds,numdates; if ( (method= jstr(argjson,"method")) == 0 ) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index f859aea5e..b65fa9556 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -32,7 +32,7 @@ char *LP_numutxos() return(jprint(retjson,1)); } -char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port +char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port { char *method,*userpass,*base,*rel,*coin,*passphrase,*retstr = 0; int32_t authenticated=0,changed,flag = 0; cJSON *retjson,*reqjson = 0; struct iguana_info *ptr; method = jstr(argjson,"method"); @@ -169,6 +169,7 @@ unlockedspend(coin, txid)\n\ opreturndecrypt(coin, txid, passphrase)\n\ getendpoint(port=5555)\n\ getfee(coin)\n\ +sleep(seconds=60)\n\ listtransactions(coin, address, count=10, skip=0)\n\ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ \"}")); @@ -318,6 +319,13 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ LP_millistats_update(0); return(clonestr("{\"result\":\"success\"}")); } + else if ( strcmp(method,"sleep") == 0 ) + { + if ( jint(argjson,"seconds") == 0 ) + sleep(60); + else sleep(jint(argjson,"seconds")); + return(clonestr("{\"result\":\"success\",\"status\":\"feeling good after sleeping\"}")); + } else if ( strcmp(method,"getprices") == 0 ) return(LP_prices()); else if ( strcmp(method,"getpeers") == 0 ) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 6ad01bd30..d715efc8c 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -204,7 +204,7 @@ char *LP_command_process(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson return(0); if ( stats_JSONonly != 0 || LP_tradecommand(ctx,myipaddr,pubsock,argjson,data,datalen) <= 0 ) { - if ( (retstr= stats_JSON(ctx,myipaddr,pubsock,argjson,"127.0.0.1",stats_JSONonly)) != 0 ) + if ( (retstr= stats_JSON(ctx,0,myipaddr,pubsock,argjson,"127.0.0.1",stats_JSONonly)) != 0 ) { //printf("%s PULL.[%d]-> (%s)\n",myipaddr != 0 ? myipaddr : "127.0.0.1",datalen,retstr); //if ( pubsock >= 0 ) //strncmp("{\"error\":",retstr,strlen("{\"error\":")) != 0 && @@ -425,7 +425,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int //portable_mutex_lock(&LP_commandmutex); if ( LP_tradecommand(ctx,myipaddr,pubsock,argjson,0,0) <= 0 ) { - if ( (retstr= stats_JSON(ctx,myipaddr,pubsock,argjson,remoteaddr,0)) != 0 ) + if ( (retstr= stats_JSON(ctx,0,myipaddr,pubsock,argjson,remoteaddr,0)) != 0 ) free(retstr); } //portable_mutex_unlock(&LP_commandmutex); diff --git a/iguana/exchanges/fasttest b/iguana/exchanges/fasttest new file mode 100755 index 000000000..bdfb417db --- /dev/null +++ b/iguana/exchanges/fasttest @@ -0,0 +1,6 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sleep\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}" +curl --url "http://127.0.0.1:7783" --data "{\"queueid\":1,\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}" diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 234565e32..c35046538 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -37,7 +37,7 @@ void PNACL_message(char *arg,...) uint32_t DOCKERFLAG; #define MAX(a,b) ((a) > (b) ? (a) : (b)) -char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port); +char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port); #include "stats.c" void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveask,double highbid,double lowask,double PAXPRICES[32]); diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 6c8daa4f5..7649ea627 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -28,7 +28,7 @@ #define STATS_DESTDIR "/var/www/html" #define STATS_DEST "/var/www/html/DEXstats.json" #include "DEXstats.h" -char *stats_JSON(void *ctx,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port); +char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port); void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly,uint32_t queueid); extern uint32_t DOCKERFLAG; @@ -530,7 +530,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po //free(buf); //while ( retstr == 0 ) // usleep(10000); - if ( (retstr= stats_JSON(ctx,"127.0.0.1",-1,argjson,remoteaddr,port)) != 0 ) + if ( (retstr= stats_JSON(ctx,0,"127.0.0.1",-1,argjson,remoteaddr,port)) != 0 ) { if ( (retitem= cJSON_Parse(retstr)) != 0 ) jaddi(retarray,retitem); @@ -543,7 +543,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po //free(buf); //while ( retstr == 0 ) // usleep(10000); - if ( (retstr= stats_JSON(ctx,myipaddr,-1,argjson,remoteaddr,port)) != 0 ) + if ( (retstr= stats_JSON(ctx,0,myipaddr,-1,argjson,remoteaddr,port)) != 0 ) { if ( (retitem= cJSON_Parse(retstr)) != 0 ) jaddi(retarray,retitem); @@ -576,7 +576,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid); free(buf); retstr = clonestr("{\"result\":\"success\",\"status\":\"queued\"}"); - } else retstr = stats_JSON(ctx,"127.0.0.1",-1,arg,remoteaddr,port); + } else retstr = stats_JSON(ctx,jint(arg,"fast"),"127.0.0.1",-1,arg,remoteaddr,port); } else retstr = clonestr("{\"error\":\"invalid remote method\"}"); #else if ( IPC_ENDPOINT >= 0 && (queueid= juint(arg,"queueid")) > 0 ) @@ -584,7 +584,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po buf = jprint(arg,0); LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid); free(buf); - } else retstr = stats_JSON(ctx,myipaddr,-1,arg,remoteaddr,port); + } else retstr = stats_JSON(ctx,jint(arg,"fast"),myipaddr,-1,arg,remoteaddr,port); #endif } free_json(argjson); @@ -626,7 +626,7 @@ int32_t iguana_getheadersize(char *buf,int32_t recvlen) } uint16_t RPC_port; -extern portable_mutex_t LP_commandmutex,LP_gcmutex; +extern portable_mutex_t LP_gcmutex; extern struct rpcrequest_info *LP_garbage_collector; void LP_rpc_processreq(void *_ptr) @@ -884,7 +884,7 @@ void stats_rpcloop(void *args) #ifndef FROM_MARKETMAKER -portable_mutex_t LP_commandmutex; +//portable_mutex_t LP_commandmutex; uint16_t LP_RPCPORT = 7763; void stats_kvjson(FILE *logfp,int32_t height,int32_t savedheight,uint32_t timestamp,char *key,cJSON *kvjson,bits256 pubkey,bits256 sigprev)