diff --git a/src/main.cpp b/src/main.cpp index 3bfbc3f2c..d7b0c1f7a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1678,7 +1678,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos) } // Check the header komodo_block2pubkey33(pubkey33,(CBlock *)&block); - if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus()))) + if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime))) { int32_t i; for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey33[i]); @@ -3757,7 +3757,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl // Check proof of work matches claimed amount /*komodo_index2pubkey33(pubkey33,pindex,height); - if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) ) + if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus(),blockhdr.nTime) ) return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");*/ return true; } @@ -3814,7 +3814,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) ) return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution"); komodo_block2pubkey33(pubkey33,(CBlock *)&block); - if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus()) ) + if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime) ) { //komodo_reverify_blockcheck(state,height,pindex); return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash"); diff --git a/src/pow.cpp b/src/pow.cpp index ebb5c774c..6fb357ac6 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -192,7 +192,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int return true; if ( ASSETCHAINS_SYMBOL[0] != 0 || height > 792000 ) { - if ( 1 && height > 792000 ) + if ( 0 && height > 792000 ) { for (i=31; i>=0; i--) printf("%02x",((uint8_t *)&hash)[i]); @@ -222,6 +222,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int return true; } + arith_uint256 GetBlockProof(const CBlockIndex& block) { arith_uint256 bnTarget; diff --git a/src/pow.h b/src/pow.h index 3edec74ac..213fe228d 100644 --- a/src/pow.h +++ b/src/pow.h @@ -25,7 +25,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&); /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */ -bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&); +bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&,uint32_t blocktime); arith_uint256 GetBlockProof(const CBlockIndex& block); /** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */ diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index da1d5207f..d141c42c4 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -257,7 +257,7 @@ UniValue generate(const UniValue& params, bool fHelp) LOCK(cs_main); pblock->nSolution = soln; solutionTargetChecks.increment(); - return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus()); + return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus(),pblock->nTime); }; bool found = EhBasicSolveUncancellable(n, k, curr_state, validBlock); ehSolverRuns.increment(); diff --git a/src/txdb.cpp b/src/txdb.cpp index f37f66daf..3e4602d32 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -530,7 +530,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() diskindex.ToString(), pindexNew->ToString()); uint8_t pubkey33[33]; komodo_index2pubkey33(pubkey33,pindexNew,pindexNew->nHeight); - if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus())) + if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus(),pindexNew->nHeight)) return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString()); pcursor->Next(); } else {