From 1aa390ff475a61e3563df86a9bfcd55b0d8625df Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Wed, 13 Mar 2019 12:15:37 -0700 Subject: [PATCH] WIP: merged mining. --- src/primitives/block.cpp | 8 ++++---- src/primitives/block.h | 28 ++++------------------------ src/rpc/mining.cpp | 9 +++++---- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 3d4623f05..91ba4a45c 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -46,7 +46,7 @@ uint256 CBlockHeader::GetPoWHash() const // Merged mining. cryptonote::tx_extra_keva_blockhash keva_blockhash; - if (!cryptonote::get_keva_blockhash_from_extra(cnHeader.aux_pow->miner_tx.extra, keva_blockhash)) { + if (!cryptonote::get_keva_blockhash_from_extra(cnHeader.aux_pow_ptr->miner_tx.extra, keva_blockhash)) { return DIFFICULTY_1; } uint256 actualHash = GetHash(); @@ -55,14 +55,14 @@ uint256 CBlockHeader::GetPoWHash() const } crypto::hash miner_tx_hash; - if (!cryptonote::get_transaction_hash(cnHeader.aux_pow->miner_tx, miner_tx_hash)) { + if (!cryptonote::get_transaction_hash(cnHeader.aux_pow_ptr->miner_tx, miner_tx_hash)) { return DIFFICULTY_1; } crypto::hash aux_blocks_merkle_root; crypto::tree_hash_from_branch( - reinterpret_cast(cnHeader.aux_pow->merkle_branch.data()), - cnHeader.aux_pow->merkle_branch.size(), + reinterpret_cast(cnHeader.aux_pow_ptr->merkle_branch.data()), + cnHeader.aux_pow_ptr->merkle_branch.size(), reinterpret_cast(&miner_tx_hash), 0, reinterpret_cast(&aux_blocks_merkle_root)); diff --git a/src/primitives/block.h b/src/primitives/block.h index ec7f9100b..0fdffded8 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -22,27 +23,6 @@ public: // merkel tree whose root is merkle_root. std::vector merkle_branch; - uint256 CheckMerkleBranch (uint256 hash, - const std::vector& vMerkleBranch, - int nIndex) - { - if (nIndex == -1) { - return uint256(); - } -#if 0 - for (std::vector::const_iterator it(vMerkleBranch.begin()); - it != vMerkleBranch.end(); ++it) { - if (nIndex & 1) { - hash = Hash(BEGIN(*it), END(*it), BEGIN(hash), END(hash)); - } else { - hash = Hash(BEGIN(hash), END(hash), BEGIN(*it), END(*it)); - } - nIndex >>= 1; - } - return hash; -#endif - } - // load template