aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-12-13 19:47:47 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-25 13:43:17 +0000
commit547a9708de91c175ceab0ddde93785ba93c9efca (patch)
treecfaa3baf0447a7e4104c5416c091ffcb539ae5e2 /src/cryptonote_protocol
parentblockchain: avoid unneeded block copy (diff)
downloadmonero-547a9708de91c175ceab0ddde93785ba93c9efca.tar.xz
cryptonote: block parsing + hash calculation speedup
This saves a duplicate serialization step
Diffstat (limited to '')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index b33867e8b..e1675e686 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -993,7 +993,8 @@ namespace cryptonote
return 1;
}
- if(!parse_and_validate_block_from_blob(block_entry.block, b))
+ crypto::hash block_hash;
+ if(!parse_and_validate_block_from_blob(block_entry.block, b, block_hash))
{
LOG_ERROR_CCONTEXT("sent wrong block: failed to parse and validate block: "
<< epee::string_tools::buff_to_hex_nodelimer(block_entry.block) << ", dropping connection");
@@ -1012,7 +1013,6 @@ namespace cryptonote
if (start_height == std::numeric_limits<uint64_t>::max())
start_height = boost::get<txin_gen>(b.miner_tx.vin[0]).height;
- const crypto::hash block_hash = get_block_hash(b);
auto req_it = context.m_requested_objects.find(block_hash);
if(req_it == context.m_requested_objects.end())
{
@@ -1119,13 +1119,13 @@ namespace cryptonote
<< ", we need " << previous_height);
block new_block;
- if (!parse_and_validate_block_from_blob(blocks.back().block, new_block))
+ crypto::hash last_block_hash;
+ if (!parse_and_validate_block_from_blob(blocks.back().block, new_block, last_block_hash))
{
MERROR(context << "Failed to parse block, but it should already have been parsed");
m_block_queue.remove_spans(span_connection_id, start_height);
continue;
}
- const crypto::hash last_block_hash = cryptonote::get_block_hash(new_block);
if (m_core.have_block(last_block_hash))
{
const uint64_t subchain_height = start_height + blocks.size();