aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities/blockchain_import.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_utilities/blockchain_import.cpp')
-rw-r--r--src/blockchain_utilities/blockchain_import.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp
index 2a8a6f494..e4efdc3cb 100644
--- a/src/blockchain_utilities/blockchain_import.cpp
+++ b/src/blockchain_utilities/blockchain_import.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2018, The Monero Project
+// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -193,8 +193,16 @@ int check_flush(cryptonote::core &core, std::vector<block_complete_entry> &block
}
core.prevalidate_block_hashes(core.get_blockchain_storage().get_db().height(), hashes);
- core.prepare_handle_incoming_blocks(blocks);
+ std::vector<block> pblocks;
+ core.prepare_handle_incoming_blocks(blocks, pblocks);
+ if (!pblocks.empty() && pblocks.size() != blocks.size())
+ {
+ MERROR("Unexpected parsed blocks size");
+ core.cleanup_handle_incoming_blocks();
+ return 1;
+ }
+ size_t blockidx = 0;
for(const block_complete_entry& block_entry: blocks)
{
// process transactions
@@ -215,7 +223,7 @@ int check_flush(cryptonote::core &core, std::vector<block_complete_entry> &block
block_verification_context bvc = boost::value_initialized<block_verification_context>();
- core.handle_incoming_block(block_entry.block, bvc, false); // <--- process block
+ core.handle_incoming_block(block_entry.block, pblocks.empty() ? NULL : &pblocks[blockidx++], bvc, false); // <--- process block
if(bvc.m_verifivation_failed)
{
@@ -455,7 +463,7 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path
}
else
{
- std::vector<transaction> txs;
+ std::vector<std::pair<transaction, blobdata>> txs;
std::vector<transaction> archived_txs;
archived_txs = bp.txs;
@@ -472,7 +480,7 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path
// because add_block() calls
// add_transaction(blk_hash, blk.miner_tx) first, and
// then a for loop for the transactions in txs.
- txs.push_back(tx);
+ txs.push_back(std::make_pair(tx, tx_to_blob(tx)));
}
size_t block_weight;
@@ -485,7 +493,8 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path
try
{
- core.get_blockchain_storage().get_db().add_block(b, block_weight, cumulative_difficulty, coins_generated, txs);
+ uint64_t long_term_block_weight = core.get_blockchain_storage().get_next_long_term_block_weight(block_weight);
+ core.get_blockchain_storage().get_db().add_block(std::make_pair(b, block_to_blob(b)), block_weight, long_term_block_weight, cumulative_difficulty, coins_generated, txs);
}
catch (const std::exception& e)
{