aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-06 15:59:43 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-06 15:59:43 +0200
commit4ac78e1612b193b9e755d40b7c72a8cc287107a9 (patch)
tree6c61a974f9b6c38fbc38b91acd72051c3435ef66 /src/cryptonote_core
parentMerge pull request #5345 (diff)
parentcryptonote_basic: some more minor speedups (diff)
downloadmonero-4ac78e1612b193b9e755d40b7c72a8cc287107a9.tar.xz
Merge pull request #5346
c84ea299 cryptonote_basic: some more minor speedups (moneromooo-monero) e40eb2ad cryptonote_basic: speedup calculate_block_hash (moneromooo-monero) 547a9708 cryptonote: block parsing + hash calculation speedup (moneromooo-monero) 11604b6d blockchain: avoid unneeded block copy (moneromooo-monero) 8461df04 save some database calls when getting top block hash and height (moneromooo-monero) 3bbc3661 Avoid repeated (de)serialization when syncing (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp11
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp3
2 files changed, 9 insertions, 5 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 83d3044f8..73c60760b 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -3176,6 +3176,7 @@ bool Blockchain::check_fee(size_t tx_weight, uint64_t fee) const
if (version >= HF_VERSION_DYNAMIC_FEE)
{
median = m_current_block_cumul_weight_limit / 2;
+ const uint64_t blockchain_height = m_db->height();
already_generated_coins = blockchain_height ? m_db->get_block_already_generated_coins(blockchain_height - 1) : 0;
if (!get_block_reward(median, 1, already_generated_coins, base_reward, version))
return false;
@@ -4332,8 +4333,9 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
for (unsigned int j = 0; j < batches; j++, ++blockidx)
{
block &block = blocks[blockidx];
+ crypto::hash block_hash;
- if (!parse_and_validate_block_from_blob(it->block, block))
+ if (!parse_and_validate_block_from_blob(it->block, block, block_hash))
return false;
// check first block and skip all blocks if its not chained properly
@@ -4346,7 +4348,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
return true;
}
}
- if (have_block(get_block_hash(block)))
+ if (have_block(block_hash))
blocks_exist = true;
std::advance(it, 1);
@@ -4356,11 +4358,12 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
for (unsigned i = 0; i < extra && !blocks_exist; i++, blockidx++)
{
block &block = blocks[blockidx];
+ crypto::hash block_hash;
- if (!parse_and_validate_block_from_blob(it->block, block))
+ if (!parse_and_validate_block_from_blob(it->block, block, block_hash))
return false;
- if (have_block(get_block_hash(block)))
+ if (have_block(block_hash))
blocks_exist = true;
std::advance(it, 1);
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index da413bbe2..8ab7d174c 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1432,7 +1432,8 @@ namespace cryptonote
block lb;
if (!b)
{
- if(!parse_and_validate_block_from_blob(block_blob, lb))
+ crypto::hash block_hash;
+ if(!parse_and_validate_block_from_blob(block_blob, lb, block_hash))
{
LOG_PRINT_L1("Failed to parse and validate new block");
bvc.m_verifivation_failed = true;