From 0570045c8744a3a4f13206da0c76c92523805e9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Oct 2016 11:08:37 -0300 Subject: [PATCH] test --- src/komodo.h | 29 ++++++++++++----------------- src/main.cpp | 4 ++-- src/pow.cpp | 4 ++-- src/rpcmining.cpp | 4 ++-- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b38ad3b50..4e9138fcd 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -34,36 +34,31 @@ void komodo_connectblock(CBlock *block) // update voting results and official (height, notaries[]) } -int32_t komodo_is_notaryblock(CBlockHeader *blockhdr) +int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp) { // extract height from coinbase // extract miner's pubkey from vout[0] // compare against elected notary pubkeys as of height + return(0); // normal PoW block +} + +int32_t komodo_is_notaryblock(CBlockHeader& blockhdr) +{ + // 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS + // -1 -> invalid, ie, prior to notarized block return(0); } -int32_t komodo_blockhdrcheck(const CBlockHeader *blockhdr,uint32_t *nBitsp) +int32_t komodo_blockhdrcheck(CBlockHeader& blockhdr,uint32_t *nBitsp) { - if ( komodo_is_notaryblock((CBlockHeader *)blockhdr) != 0 ) + if ( komodo_is_notaryblock(blockhdr) != 0 ) *nBitsp = KOMODO_MINDIFF_NBITS; - // 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS - // -1 -> invalid, ie, prior to notarized block return(0); // normal PoW block } -int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp) +int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp) { - return(0); // normal PoW block -} - -int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp) -{ - CBlockIndex *bindex = 0;//new CBlockIndex(block->GetBlockHeader()); - if ( bindex != 0 && bindex->nHeight <= NOTARIZED_HEIGHT ) - return(-1); - // 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS - // -1 -> invalid, ie, prior to notarized block - return(0); // normal PoW block + komodo_blockhdrcheck(block,nBitsp); } #endif diff --git a/src/main.cpp b/src/main.cpp index b21658d6e..4daede647 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1343,7 +1343,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos) // Check the header nBits = block.nBits; - if ( (retval= komodo_blockcheck(&block,&nBits)) == 0 ) + if ( (retval= komodo_blockcheck(block,&nBits)) == 0 ) { if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus()))) return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); @@ -2951,7 +2951,7 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f if (block.GetBlockTime() > GetAdjustedTime() + 60) return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); nBits = block.nBits; - if ( (retval= komodo_blockhdrcheck(&block,&nBits)) == 0 ) + if ( (retval= komodo_blockhdrcheck(block,&nBits)) == 0 ) { // Check Equihash solution is valid if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) ) diff --git a/src/pow.cpp b/src/pow.cpp index a87521f65..2d93a4756 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -16,14 +16,14 @@ #include "sodium.h" -int32_t komodo_is_notaryblock(CBlockHeader *pblock); +int32_t komodo_is_notaryblock(CBlockHeader& block); unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block - if (pindexLast == NULL || komodo_is_notaryblock((CBlockHeader *)pblock) != 0 ) + if (pindexLast == NULL || komodo_is_notaryblock(*pblock) != 0 ) return nProofOfWorkLimit; // Find the first block in the averaging interval diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 70b84cf04..1e22bec1c 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -115,7 +115,7 @@ Value getgenerate(const Array& params, bool fHelp) return GetBoolArg("-gen", false); } -int32_t komodo_blockcheck(CBlock *block,uint32_t *nBitsp); +int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp); Value generate(const Array& params, bool fHelp) { @@ -196,7 +196,7 @@ Value generate(const Array& params, bool fHelp) int32_t retval; uint32_t nBits; pblock->nSolution = soln; nBits = pblock->nBits; - if ( (retval= komodo_blockcheck(pblock,&nBits)) == 0 ) + if ( (retval= komodo_blockcheck(*pblock,&nBits)) == 0 ) { return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus()); } else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash