From e6aede49ae8a708cb19c39a65064bd2e49fb2781 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 27 Feb 2019 13:11:11 +0800 Subject: [PATCH] fix extremely rare bug! --- src/komodo.h | 7 +++---- src/miner.cpp | 15 ++++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a78b6848c..bd3550e38 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -630,6 +630,9 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( matched != 0 ) validated = komodo_validate_chain(srchash,*notarizedheightp); else validated = 1; + // Any notarization that is matched and has a decodable op_return is enough to pay notaries. Otherwise bugs! + if ( fJustCheck && matched != 0 ) + return(-2); if ( notarized != 0 && validated != 0 ) { //sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -697,10 +700,6 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 ) komodo_rwccdata((char *)"KMD",1,&ccdata,0); - // Because of reorgs its not possible to use notarizations that are in order. If its validated pay the notaries! - if ( fJustCheck ) - return(-2); - if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; diff --git a/src/miner.cpp b/src/miner.cpp index 4b5191d06..a567e2e20 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -154,6 +154,7 @@ CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk); uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); +int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -403,11 +404,15 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Any attempted notarization needs to be in its own block! continue; } - // this is the first one we see, add it to the block as TX1 - NotarisationNotaries = TMP_NotarisationNotaries; - dPriority = 1e16; - fNotarisationBlock = true; - fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + int32_t notarizedheight = komodo_getnotarizedheight(pblock->nTime, nHeight, script, scriptlen); + if ( notarizedheight != 0 ) + { + // this is the first one we see, add it to the block as TX1 + NotarisationNotaries = TMP_NotarisationNotaries; + dPriority = 1e16; + fNotarisationBlock = true; + fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str()); + } } } }