From d4ebd390faa180e63cd8249ac42ba53afb863f7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Mar 2019 03:03:53 -1100 Subject: [PATCH] relay --- src/cc/gamescc.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 1e8b99079..ca780b8cf 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -225,6 +225,11 @@ int32_t games_eventsign(uint32_t ×tamp,std::vector &sig,std::vecto } else return(-1); } +int32_t games_payload(CPubKey pk,uint32_t timestamp,std::vector payload) +{ + return(0); +} + UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ); std::vector sig,payload,vopret; int32_t n; CPubKey mypk; char str[67]; uint32_t timestamp = 0; @@ -236,6 +241,7 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( games_eventsign(timestamp,sig,payload,mypk) == 0 ) { GetOpReturnData(games_eventopret(timestamp,mypk,sig,payload),vopret); + games_payload(mypk,timestamp,payload); komodo_sendmessage(4,8,"events",vopret); result.push_back(Pair("result","success")); result.push_back(Pair("pubkey33",pubkey33_str(str,(uint8_t *)&mypk))); @@ -262,15 +268,26 @@ UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) void komodo_netevent(std::vector message) { - int32_t i,retval,lag; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; + int32_t i,retval,lag,lagerr=0; uint32_t timestamp,now; CPubKey pk; std::vector sig,payload; char str[67]; if ( games_eventdecode(timestamp,pk,sig,payload,message) == 'E' ) { now = (uint32_t)time(NULL); lag = now - timestamp; if ( lag < -3 || lag > 3 ) + { fprintf(stderr,"LAG ERROR "); + lagerr = lag; + } if ( (retval= games_eventsign(timestamp,sig,payload,pk)) != 0 ) fprintf(stderr,"SIG ERROR.%d ",retval); + else if ( lagerr == 0 ) + { + if ( games_payload(pk,timestamp,payload) == 0 ) // first time this is seen + { + if ( (rand() % 10) == 0 ) + komodo_sendmessage(2,2,"events",message); + } + } for (i=0; i