mirror of
https://github.com/monero-project/monero.git
synced 2026-01-13 13:27:34 -08:00
cryptonote: block parsing + hash calculation speedup
This saves a duplicate serialization step
This commit is contained in:
@@ -4283,8 +4283,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
|
||||
@@ -4297,7 +4298,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);
|
||||
@@ -4307,11 +4308,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);
|
||||
|
||||
Reference in New Issue
Block a user