aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp4
-rw-r--r--src/cryptonote_core/blockchain.h5
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp25
-rw-r--r--src/cryptonote_core/cryptonote_core.h5
4 files changed, 23 insertions, 16 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index a1bee09dc..2890af628 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -4211,13 +4211,14 @@ uint64_t Blockchain::prevalidate_block_hashes(uint64_t height, const std::vector
// vs [k_image, output_keys] (m_scan_table). This is faster because it takes advantage of bulk queries
// and is threaded if possible. The table (m_scan_table) will be used later when querying output
// keys.
-bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry)
+bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks)
{
MTRACE("Blockchain::" << __func__);
TIME_MEASURE_START(prepare);
bool stop_batch;
uint64_t bytes = 0;
size_t total_txs = 0;
+ blocks.clear();
// Order of locking must be:
// m_incoming_tx_lock (optional)
@@ -4264,7 +4265,6 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
bool blocks_exist = false;
tools::threadpool& tpool = tools::threadpool::getInstance();
unsigned threads = tpool.get_max_concurrency();
- std::vector<block> blocks;
blocks.resize(blocks_entry.size());
if (1)
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 6e966781d..9d928e386 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -230,11 +230,12 @@ namespace cryptonote
/**
* @brief performs some preprocessing on a group of incoming blocks to speed up verification
*
- * @param blocks a list of incoming blocks
+ * @param blocks_entry a list of incoming blocks
+ * @param blocks the parsed blocks
*
* @return false on erroneous blocks, else true
*/
- bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks);
+ bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
/**
* @brief incoming blocks post-processing, cleanup, and disk sync
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 0d29f996a..bab0e2dd9 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1330,7 +1330,8 @@ namespace cryptonote
m_miner.resume();
return false;
}
- prepare_handle_incoming_blocks(blocks);
+ std::vector<block> pblocks;
+ prepare_handle_incoming_blocks(blocks, pblocks);
m_blockchain_storage.add_new_block(b, bvc);
cleanup_handle_incoming_blocks(true);
//anyway - update miner template
@@ -1381,10 +1382,10 @@ namespace cryptonote
}
//-----------------------------------------------------------------------------------------------
- bool core::prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks)
+ bool core::prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks)
{
m_incoming_tx_lock.lock();
- m_blockchain_storage.prepare_handle_incoming_blocks(blocks);
+ m_blockchain_storage.prepare_handle_incoming_blocks(blocks_entry, blocks);
return true;
}
@@ -1401,7 +1402,7 @@ namespace cryptonote
}
//-----------------------------------------------------------------------------------------------
- bool core::handle_incoming_block(const blobdata& block_blob, block_verification_context& bvc, bool update_miner_blocktemplate)
+ bool core::handle_incoming_block(const blobdata& block_blob, const block *b, block_verification_context& bvc, bool update_miner_blocktemplate)
{
TRY_ENTRY();
@@ -1417,14 +1418,18 @@ namespace cryptonote
return false;
}
- block b = AUTO_VAL_INIT(b);
- if(!parse_and_validate_block_from_blob(block_blob, b))
+ block lb;
+ if (!b)
{
- LOG_PRINT_L1("Failed to parse and validate new block");
- bvc.m_verifivation_failed = true;
- return false;
+ if(!parse_and_validate_block_from_blob(block_blob, lb))
+ {
+ LOG_PRINT_L1("Failed to parse and validate new block");
+ bvc.m_verifivation_failed = true;
+ return false;
+ }
+ b = &lb;
}
- add_new_block(b, bvc);
+ add_new_block(*b, bvc);
if(update_miner_blocktemplate && bvc.m_added_to_main_chain)
update_miner_block_template();
return true;
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 131440511..6d0ff098d 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -146,20 +146,21 @@ namespace cryptonote
* optionally updates the miner's block template.
*
* @param block_blob the block to be added
+ * @param block the block to be added, or NULL
* @param bvc return-by-reference metadata context about the block's validity
* @param update_miner_blocktemplate whether or not to update the miner's block template
*
* @return false if loading new checkpoints fails, or the block is not
* added, otherwise true
*/
- bool handle_incoming_block(const blobdata& block_blob, block_verification_context& bvc, bool update_miner_blocktemplate = true);
+ bool handle_incoming_block(const blobdata& block_blob, const block *b, block_verification_context& bvc, bool update_miner_blocktemplate = true);
/**
* @copydoc Blockchain::prepare_handle_incoming_blocks
*
* @note see Blockchain::prepare_handle_incoming_blocks
*/
- bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks);
+ bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
/**
* @copydoc Blockchain::cleanup_handle_incoming_blocks