From afa0b894008073dc3f908f8fb2c79e3facb5fb20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 01:58:45 -1100 Subject: [PATCH 1/4] Reduce keystrokes three --- src/cc/gamescc.cpp | 48 ++++++++++++++++++++++---------------------- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 29df990b5..89efcc6d2 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -136,30 +136,6 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } -UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result(UniValue::VOBJ); std::vector payload; int32_t n; - if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) - { - if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) - { - komodo_sendmessage(4,8,"events",payload); - result.push_back(Pair("result","success")); - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","couldnt parsehexdata")); - } - } - else - { - result.push_back(Pair("result","error")); - result.push_back(Pair("error","not enough params")); - } - return(result); -} - UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); @@ -178,6 +154,30 @@ UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); std::vector payload; int32_t n; + if ( params != 0 && (n= cJSON_GetArraySize(params)) == 1 ) + { + if ( payments_parsehexdata(payload,jitem(params,0),0) == 0 ) + { + komodo_sendmessage(4,8,"events",payload); + result.push_back(Pair("result","success")); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","couldnt parsehexdata")); + } + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("error","not enough params")); + } + return(result); +} + void komodo_netevent(std::vector payload) { int32_t i; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 495fa8774..0d6d9b3d4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -918,7 +918,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; if ( txfee == 0 ) - txfee = 10000; + txfee = 1000; // smaller than normal on purpose rogue_univalue(result,"keystrokes",-1,-1); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { From 00a8e9f59c2579c18f716ca1f21724b412c7b10d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 07:18:54 -1100 Subject: [PATCH 2/4] Force 1000 sats for keystrokes --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 0d6d9b3d4..caf37b566 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -917,7 +917,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param int32_t nextheight = komodo_nextheight(); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),nextheight); UniValue result(UniValue::VOBJ); CPubKey roguepk,mypk; uint256 gametxid,playertxid,batontxid; int64_t batonvalue,buyin; std::vector keystrokes,playerdata; int32_t numplayers,regslot,numkeys,batonht,batonvout,n,elapsed,gameheight,maxplayers; CTransaction tx; CTxOut txout; char *keystrokestr,destaddr[64]; std::string rawtx,symbol,pname; bits256 t; uint8_t mypriv[32]; - if ( txfee == 0 ) + // if ( txfee == 0 ) txfee = 1000; // smaller than normal on purpose rogue_univalue(result,"keystrokes",-1,-1); if ( params != 0 && (n= cJSON_GetArraySize(params)) == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) From d0aa3c7e13479468e3d692462b7780bc7086bfdc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 08:03:13 -1100 Subject: [PATCH 3/4] Skip keystrokes processing unless > 5 min from last one --- src/cc/rogue/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f146cfb4d..f0c0d2a5c 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -786,10 +786,13 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { + static uint32_t lasttime; char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { + if ( waitflag == 0 && time(NULL) < lasttime+300 ) + return; if ( rs->keystrokeshex != 0 ) { if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) @@ -884,6 +887,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex), rs->keystrokeshex = 0; } } + lasttime = (uint32_t)time(NULL); } } From 219c6c4239f209fa0f1a559d7a9e568611adf66d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Mar 2019 19:56:21 -1100 Subject: [PATCH 4/4] Revert delay in keystrokes --- src/cc/rogue/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index f0c0d2a5c..f146cfb4d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -786,13 +786,10 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - static uint32_t lasttime; char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { - if ( waitflag == 0 && time(NULL) < lasttime+300 ) - return; if ( rs->keystrokeshex != 0 ) { if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 ) @@ -887,7 +884,6 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * free(rs->keystrokeshex), rs->keystrokeshex = 0; } } - lasttime = (uint32_t)time(NULL); } }