From f6608b5a0dc29c7c387381aa176c452b94e941ab Mon Sep 17 00:00:00 2001 From: Michael Toutonghi Date: Thu, 17 May 2018 22:58:30 -0700 Subject: [PATCH] cleanup --- src/chain.h | 10 ++++++++++ src/komodo_bitcoind.h | 2 +- src/main.cpp | 8 ++++---- src/pow.cpp | 5 +---- src/primitives/block.h | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/chain.h b/src/chain.h index a28e4e44a..8276b2596 100644 --- a/src/chain.h +++ b/src/chain.h @@ -321,6 +321,16 @@ public: //! Efficiently find an ancestor of this block. CBlockIndex* GetAncestor(int height); const CBlockIndex* GetAncestor(int height) const; + + int32_t GetVerusPOSTarget() const + { + return GetBlockHeader().GetVerusPOSTarget(); + } + + bool IsVerusPOSBlock() const + { + return GetBlockHeader().IsVerusPOSBlock(); + } }; /** Used to marshal pointers into hashes for db storage. */ diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 840e01472..7fdbc63b6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1270,7 +1270,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) arith_uint256 target, hash; CTransaction tx; - if (!pblock->isVerusPOSBlock()) + if (!pblock->IsVerusPOSBlock()) return false; char voutaddr[64],destaddr[64]; diff --git a/src/main.cpp b/src/main.cpp index 3d520e4e7..03eaa0647 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6025,8 +6025,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, for (; pindex; pindex = chainActive.Next(pindex)) { CBlockHeader h = pindex->GetBlockHeader(); - printf("size.%i, solution size.%i\n", (int)sizeof(h), (int)h.nSolution.size()); - printf("hash.%s prevhash.%s nonce.%s\n", h.GetHash().ToString().c_str(), h.hashPrevBlock.ToString().c_str(), h.nNonce.ToString().c_str()); + //printf("size.%i, solution size.%i\n", (int)sizeof(h), (int)h.nSolution.size()); + //printf("hash.%s prevhash.%s nonce.%s\n", h.GetHash().ToString().c_str(), h.hashPrevBlock.ToString().c_str(), h.nNonce.ToString().c_str()); vHeaders.push_back(pindex->GetBlockHeader()); if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) break; @@ -6196,8 +6196,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CBlockIndex *pindexLast = NULL; BOOST_FOREACH(const CBlockHeader& header, headers) { - printf("size.%i, solution size.%i\n", (int)sizeof(header), (int)header.nSolution.size()); - printf("hash.%s prevhash.%s nonce.%s\n", header.GetHash().ToString().c_str(), header.hashPrevBlock.ToString().c_str(), header.nNonce.ToString().c_str()); + //printf("size.%i, solution size.%i\n", (int)sizeof(header), (int)header.nSolution.size()); + //printf("hash.%s prevhash.%s nonce.%s\n", header.GetHash().ToString().c_str(), header.hashPrevBlock.ToString().c_str(), header.nNonce.ToString().c_str()); CValidationState state; if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) { diff --git a/src/pow.cpp b/src/pow.cpp index 70319ca34..49d03d5c2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -323,7 +323,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t return error("CheckProofOfWork(): nBits below minimum work"); // Check proof of work matches claimed amount - if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.isVerusPOSBlock() ) + if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() ) { if ( KOMODO_LOADINGBLOCKS != 0 ) return true; @@ -357,7 +357,6 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t return true; } - arith_uint256 GetBlockProof(const CBlockIndex& block) { arith_uint256 bnTarget; @@ -365,8 +364,6 @@ arith_uint256 GetBlockProof(const CBlockIndex& block) bool fOverflow; bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); - // TODO(miketout): proof of stake blocks must be marked as having the minimum POW in this context - if (fNegative || fOverflow || bnTarget == 0) return 0; // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256 diff --git a/src/primitives/block.h b/src/primitives/block.h index f46943f99..c7a379172 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -104,7 +104,7 @@ public: return nBits; } - bool isVerusPOSBlock() const + bool IsVerusPOSBlock() const { arith_uint256 arNonce = UintToArith256(nNonce); arith_uint256 tmpNonce = ((arNonce << 128) >> 128);