From d27afb07eb3c6b0a03f684a1c5585d56af32bda2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 14 Sep 2016 06:22:24 -0300 Subject: [PATCH] block check overrides --- src/komodo.h | 5 +++++ src/main.cpp | 37 +++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d84217e37..8d56c0a8c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -25,5 +25,10 @@ int32_t komodo_checkmsg(void *bitcoinpeer,uint8_t *data,int32_t datalen) return(0); } +int32_t komodo_blockcheck(void *block) +{ + fprintf(stderr,"check block %p\n",block); + return(-1); +} #endif diff --git a/src/main.cpp b/src/main.cpp index dbd8a7f92..9e66f7b99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "komodo.h" #include "main.h" #include "sodium.h" @@ -42,6 +41,8 @@ using namespace std; # error "Bitcoin cannot be compiled without assertions." #endif +extern "C" int32_t komodo_blockcheck(void *block); + /** * Global state */ @@ -1349,10 +1350,12 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos) } // Check the header - if (!(CheckEquihashSolution(&block, Params()) && - CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus()))) - return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); - + if ( komodo_blockcheck((void *)&block) < 0 ) + { + if (!(CheckEquihashSolution(&block, Params()) && + CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus()))) + return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); + } return true; } @@ -2939,21 +2942,22 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW) { - // Check Equihash solution is valid - if (fCheckPOW && !CheckEquihashSolution(&block, Params())) - return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"), - REJECT_INVALID, "invalid-solution"); - - // Check proof of work matches claimed amount - if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) - return state.DoS(50, error("CheckBlockHeader(): proof of work failed"), - REJECT_INVALID, "high-hash"); - + if ( komodo_blockcheck((void *)&block) < 0 ) + { + // Check Equihash solution is valid + if (fCheckPOW && !CheckEquihashSolution(&block, Params())) + return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"), + REJECT_INVALID, "invalid-solution"); + + // Check proof of work matches claimed amount + if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) + return state.DoS(50, error("CheckBlockHeader(): proof of work failed"), + REJECT_INVALID, "high-hash"); + } // Check timestamp if (block.GetBlockTime() > GetAdjustedTime() + 600) return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"), REJECT_INVALID, "time-too-new"); - return true; } @@ -4096,6 +4100,7 @@ string GetWarnings(string strFor) // // Messages // +#include "komodo.h" bool static AlreadyHave(const CInv& inv)