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.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp
index 8b7b0d3cb..0a7efccc1 100644
--- a/src/blockchain_utilities/blockchain_import.cpp
+++ b/src/blockchain_utilities/blockchain_import.cpp
@@ -169,6 +169,26 @@ int check_flush(cryptonote::core &core, std::list<block_complete_entry> &blocks,
if (!force && blocks.size() < db_batch_size)
return 0;
+ // wait till we can verify a full HOH without extra, for speed
+ uint64_t new_height = core.get_blockchain_storage().get_db().height() + blocks.size();
+ if (!force && new_height % HASH_OF_HASHES_STEP)
+ return 0;
+
+ std::list<crypto::hash> hashes;
+ for (const auto &b: blocks)
+ {
+ cryptonote::block block;
+ if (!parse_and_validate_block_from_blob(b.block, block))
+ {
+ MERROR("Failed to parse block: "
+ << epee::string_tools::pod_to_hex(get_blob_hash(b.block)));
+ core.cleanup_handle_incoming_blocks();
+ return 1;
+ }
+ hashes.push_back(cryptonote::get_block_hash(block));
+ }
+ core.prevalidate_block_hashes(core.get_blockchain_storage().get_db().height(), hashes);
+
core.prepare_handle_incoming_blocks(blocks);
for(const block_complete_entry& block_entry: blocks)
@@ -585,10 +605,7 @@ int main(int argc, char* argv[])
const command_line::arg_descriptor<bool> arg_resume = {"resume",
"Resume from current height if output database already exists", true};
- //command_line::add_arg(desc_cmd_sett, command_line::arg_data_dir, default_data_path.string());
- //command_line::add_arg(desc_cmd_sett, command_line::arg_testnet_data_dir, default_testnet_data_path.string());
command_line::add_arg(desc_cmd_sett, arg_input_file);
- //command_line::add_arg(desc_cmd_sett, arg_testnet_on);
command_line::add_arg(desc_cmd_sett, arg_log_level);
command_line::add_arg(desc_cmd_sett, arg_database);
command_line::add_arg(desc_cmd_sett, arg_batch_size);