From 755ead988942620ba4f1a74a68af5dba7236f2a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 6 Nov 2016 10:09:37 -0300 Subject: [PATCH] test --- src/komodo.h | 12 +++++++---- src/komodo_gateway.h | 50 ++++++++++++++++++++++++-------------------- src/miner.cpp | 23 ++++++++++++++------ 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c62382f1d..d6da8ba53 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,6 +17,8 @@ #define H_KOMODO_H // Todo: handle reorg: clear all entries above reorged height +// smooth consensus price +// #include #include @@ -29,6 +31,8 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n char *komodo_issuemethod(char *method,char *params,uint16_t port); #define GENESIS_NBITS 0x1f00ffff +#define KOMODO_MINRATIFY 7 + #include "komodo_globals.h" #include "komodo_utils.h" //queue_t DepositsQ,PendingsQ; @@ -326,13 +330,13 @@ int32_t komodo_voutupdate(int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen, int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) { - if ( isspecial != 0 && numvalid > 13 ) + if ( isspecial != 0 && numvalid >= KOMODO_MINRATIFY ) return(1); else return(0); } // Special tx have vout[0] -> CRYPTO777 -// with more than 13 pay2pubkey outputs -> ratify +// with more than KOMODO_MINRATIFY pay2pubkey outputs -> ratify // if all outputs to notary -> notary utxo // if txi == 0 && 2 outputs and 2nd OP_RETURN, len == 32*2+4 -> notarized, 1st byte 'P' -> pricefeed // OP_RETURN: 'D' -> deposit, 'W' -> withdraw @@ -350,8 +354,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fprintf(stderr,"komodo_connect.(%s) waiting for realtime RT.%u now.%u\n",ASSETCHAINS_SYMBOL,KOMODO_REALTIME,(uint32_t)time(NULL)); sleep(3); } - KOMODO_INITDONE = (uint32_t)time(NULL); } + KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; @@ -422,7 +426,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( komodo_isratify(1,numvalid) > 7 ) + if ( komodo_isratify(1,numvalid) >= KOMODO_MINRATIFY && numvouts > 13 ) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7d6b71039..bdad3d0ba 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -217,7 +217,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 tokomodo = (komodo_is_issuer() == 0); if ( opretbuf[0] == ((tokomodo == 0) ? 'D' : 'W') ) { - if ( opretlen == 34 ) + if ( opretlen == 34 ) // any KMD tx { if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { @@ -232,35 +232,38 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(tokomodo,destaddr,pubkey33,coinaddr,height,base,fiatoshis); typestr = "deposit"; - if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 && shortflag == ASSETCHAINS_SHORTFLAG ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) height.%d\n",dstr(checktoshis),dstr(value),destaddr,height); - if ( value >= checktoshis && shortflag == ASSETCHAINS_SHORTFLAG ) + if ( shortflag == 0 ) { - if ( komodo_paxfind(&space,txid,vout) == 0 ) - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) height.%d\n",dstr(checktoshis),dstr(value),destaddr,height); + if ( value >= checktoshis ) + { + if ( komodo_paxfind(&space,txid,vout) == 0 ) + komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height); + } } - } - else if ( tokomodo != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) - { - for (i=0; i 13 ) + else if ( numvouts >= KOMODO_MINRATIFY ) typestr = "ratify"; } @@ -397,9 +400,10 @@ void komodo_gateway_iteration(char *symbol) { for (i=0; i<1000 && KMDHEIGHT= 0 ) + solver = "tromp"; + solver = "default"; assert(solver == "tromp" || solver == "default"); LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k); - //fprintf(stderr,"Mining with %s\n",solver.c_str()); + fprintf(stderr,"Mining with %s\n",solver.c_str()); std::mutex m_cs; bool cancelSolver = false; boost::signals2::connection c = uiInterface.NotifyBlockTip.connect( @@ -606,10 +617,10 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) return false; - if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+30 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+20 ) { - printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+30-time(NULL))); - sleep(Mining_start+30-time(NULL)); + printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+20-time(NULL))); + sleep(Mining_start+20-time(NULL)); } // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); @@ -639,7 +650,7 @@ void static BitcoinMiner(CWallet *pwallet) }; // TODO: factor this out into a function with the same API for each solver. - if (solver == "tromp") { + if (solver == "tromp" && notaryid >= 0 ) { // Create solver and initialize it. equi eq(1); eq.setstate(&curr_state);