diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-10-22 10:06:10 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-10-22 10:06:10 -0500 |
commit | 6f202844b5550b28674b27998cd2edc23c9735fe (patch) | |
tree | 5c97850136fc63b80815f40b53e06dfb80ed4b03 /src/cryptonote_core/blockchain.cpp | |
parent | Merge pull request #5990 (diff) | |
parent | blockchain: fill in cumulative block weight for alt blocks (diff) | |
download | monero-6f202844b5550b28674b27998cd2edc23c9735fe.tar.xz |
Merge pull request #5919
01f660f blockchain: fill in cumulative block weight for alt blocks (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index e3450491b..b4942d03a 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1750,6 +1750,34 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id } bei.cumulative_difficulty += current_diff; + bei.block_cumulative_weight = cryptonote::get_transaction_weight(b.miner_tx); + for (const crypto::hash &txid: b.tx_hashes) + { + cryptonote::tx_memory_pool::tx_details td; + cryptonote::blobdata blob; + if (m_tx_pool.get_transaction_info(txid, td)) + { + bei.block_cumulative_weight += td.weight; + } + else if (m_db->get_pruned_tx_blob(txid, blob)) + { + cryptonote::transaction tx; + if (!cryptonote::parse_and_validate_tx_base_from_blob(blob, tx)) + { + MERROR_VER("Block with id: " << epee::string_tools::pod_to_hex(id) << " (as alternative) refers to unparsable transaction hash " << txid << "."); + bvc.m_verifivation_failed = true; + return false; + } + bei.block_cumulative_weight += cryptonote::get_pruned_transaction_weight(tx); + } + else + { + // we can't determine the block weight, set it to 0 and break out of the loop + bei.block_cumulative_weight = 0; + break; + } + } + // add block to alternate blocks storage, // as well as the current "alt chain" container CHECK_AND_ASSERT_MES(!m_db->get_alt_block(id, NULL, NULL), false, "insertion of new alternative block returned as it already exists"); |