From 0d24f3ed022284419b048ffba4a1f9215fb25b4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 20 Oct 2016 09:24:24 -0300 Subject: [PATCH] test --- src/komodo.h | 14 +++++++++++--- src/main.cpp | 2 +- src/main.h | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7c7f8213a..ecc1ccc27 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -544,12 +544,20 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block) memcpy(pubkey33,ptr+1,33); } -void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex) +void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) { CBlock block; memset(pubkey33,0,33); - if ( pindex != 0 && ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 ) - komodo_block2pubkey33(pubkey33,block); + if ( pindex != 0 ) + { + if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 ) + komodo_block2pubkey33(pubkey33,block); + } + else + { + // height -> pubkey33 + printf("komodo_index2pubkey33 height.%d need to get pubkey33\n",height); + } } /*int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp) diff --git a/src/main.cpp b/src/main.cpp index 71d441787..ff3276fdb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2961,7 +2961,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution"); // Check proof of work matches claimed amount - komodo_index2pubkey33(pubkey33,pindex); + komodo_index2pubkey33(pubkey33,pindex,height); if ( fCheckPOW && !CheckProofOfWork(height:0,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) ) return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash"); return true; diff --git a/src/main.h b/src/main.h index c3c11c0df..da376bbe8 100644 --- a/src/main.h +++ b/src/main.h @@ -410,7 +410,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin /** Context-independent validity checks */ bool CheckBlockHeader(CBlockIndex *pindex,const CBlock& block, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW = true); -bool CheckBlock(int32_t height,const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true); +bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true); /** Context-dependent validity checks */ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex *pindexPrev);