diff options
Diffstat (limited to 'src/blockchain_utilities')
-rw-r--r-- | src/blockchain_utilities/blockchain_export.cpp | 16 | ||||
-rw-r--r-- | src/blockchain_utilities/blockchain_import.cpp | 11 | ||||
-rw-r--r-- | src/blockchain_utilities/bootstrap_file.cpp | 23 | ||||
-rw-r--r-- | src/blockchain_utilities/bootstrap_file.h | 2 |
4 files changed, 21 insertions, 31 deletions
diff --git a/src/blockchain_utilities/blockchain_export.cpp b/src/blockchain_utilities/blockchain_export.cpp index 60672eeda..78bb51ab6 100644 --- a/src/blockchain_utilities/blockchain_export.cpp +++ b/src/blockchain_utilities/blockchain_export.cpp @@ -30,6 +30,7 @@ #include "blocksdat_file.h" #include "common/command_line.h" #include "cryptonote_core/tx_pool.h" +#include "cryptonote_core/cryptonote_core.h" #include "blockchain_db/blockchain_db.h" #include "blockchain_db/db_types.h" #include "version.h" @@ -66,21 +67,16 @@ int main(int argc, char* argv[]) const command_line::arg_descriptor<std::string> arg_output_file = {"output-file", "Specify output file", "", true}; const command_line::arg_descriptor<std::string> arg_log_level = {"log-level", "0-4 or categories", ""}; const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop}; - const command_line::arg_descriptor<bool> arg_testnet_on = { - "testnet" - , "Run on testnet." - , false - }; const command_line::arg_descriptor<std::string> arg_database = { "database", available_dbs.c_str(), default_db_type }; const command_line::arg_descriptor<bool> arg_blocks_dat = {"blocksdat", "Output in blocks.dat format", blocks_dat}; - 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, cryptonote::arg_data_dir, default_data_path.string()); + command_line::add_arg(desc_cmd_sett, cryptonote::arg_testnet_data_dir, default_testnet_data_path.string()); command_line::add_arg(desc_cmd_sett, arg_output_file); - command_line::add_arg(desc_cmd_sett, arg_testnet_on); + command_line::add_arg(desc_cmd_sett, cryptonote::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_block_stop); @@ -117,12 +113,12 @@ int main(int argc, char* argv[]) LOG_PRINT_L0("Starting..."); - bool opt_testnet = command_line::get_arg(vm, arg_testnet_on); + bool opt_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on); bool opt_blocks_dat = command_line::get_arg(vm, arg_blocks_dat); std::string m_config_folder; - auto data_dir_arg = opt_testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir; + auto data_dir_arg = opt_testnet ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir; m_config_folder = command_line::get_arg(vm, data_dir_arg); std::string db_type = command_line::get_arg(vm, arg_database); diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp index 2a956dbdb..a50b0bad6 100644 --- a/src/blockchain_utilities/blockchain_import.cpp +++ b/src/blockchain_utilities/blockchain_import.cpp @@ -256,7 +256,7 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path seek_height = start_height; BootstrapFile bootstrap; - streampos pos; + std::streampos pos; // BootstrapFile bootstrap(import_file_path); uint64_t total_source_blocks = bootstrap.count_blocks(import_file_path, pos, seek_height); MINFO("bootstrap file last block number: " << total_source_blocks-1 << " (zero-based height) total blocks: " << total_source_blocks); @@ -585,11 +585,6 @@ int main(int argc, char* argv[]) const command_line::arg_descriptor<uint64_t> arg_batch_size = {"batch-size", "", db_batch_size}; const command_line::arg_descriptor<uint64_t> arg_pop_blocks = {"pop-blocks", "Remove blocks from end of blockchain", num_blocks}; const command_line::arg_descriptor<bool> arg_drop_hf = {"drop-hard-fork", "Drop hard fork subdbs", false}; - const command_line::arg_descriptor<bool> arg_testnet_on = { - "testnet" - , "Run on testnet." - , false - }; const command_line::arg_descriptor<bool> arg_count_blocks = { "count-blocks" , "Count blocks in bootstrap file and exit" @@ -674,8 +669,8 @@ int main(int argc, char* argv[]) } } - opt_testnet = command_line::get_arg(vm, arg_testnet_on); - auto data_dir_arg = opt_testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir; + opt_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on); + auto data_dir_arg = opt_testnet ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir; m_config_folder = command_line::get_arg(vm, data_dir_arg); db_arg_str = command_line::get_arg(vm, arg_database); diff --git a/src/blockchain_utilities/bootstrap_file.cpp b/src/blockchain_utilities/bootstrap_file.cpp index a004d3547..50b56eab9 100644 --- a/src/blockchain_utilities/bootstrap_file.cpp +++ b/src/blockchain_utilities/bootstrap_file.cpp @@ -134,8 +134,7 @@ bool BootstrapFile::initialize_file() bbi.block_last_pos = 0; buffer_type buffer2; - boost::iostreams::stream<boost::iostreams::back_insert_device<buffer_type>>* output_stream_header; - output_stream_header = new boost::iostreams::stream<boost::iostreams::back_insert_device<buffer_type>>(buffer2); + boost::iostreams::stream<boost::iostreams::back_insert_device<buffer_type>> output_stream_header(buffer2); uint32_t bd_size = 0; @@ -147,8 +146,8 @@ bool BootstrapFile::initialize_file() { throw std::runtime_error("Error in serialization of bootstrap::file_info size"); } - *output_stream_header << blob; - *output_stream_header << bd; + output_stream_header << blob; + output_stream_header << bd; bd = t_serializable_object_to_blob(bbi); MDEBUG("bootstrap::blocks_info size: " << bd.size()); @@ -158,12 +157,12 @@ bool BootstrapFile::initialize_file() { throw std::runtime_error("Error in serialization of bootstrap::blocks_info size"); } - *output_stream_header << blob; - *output_stream_header << bd; + output_stream_header << blob; + output_stream_header << bd; - output_stream_header->flush(); - *output_stream_header << std::string(header_size-buffer2.size(), 0); // fill in rest with null bytes - output_stream_header->flush(); + output_stream_header.flush(); + output_stream_header << std::string(header_size-buffer2.size(), 0); // fill in rest with null bytes + output_stream_header.flush(); std::copy(buffer2.begin(), buffer2.end(), std::ostreambuf_iterator<char>(*m_raw_data_file)); return true; @@ -221,7 +220,7 @@ void BootstrapFile::write_block(block& block) // now add all regular transactions for (const auto& tx_id : block.tx_hashes) { - if (tx_id == null_hash) + if (tx_id == crypto::null_hash) { throw std::runtime_error("Aborting: tx == null_hash"); } @@ -433,7 +432,7 @@ uint64_t BootstrapFile::count_bytes(std::ifstream& import_file, uint64_t blocks, uint64_t BootstrapFile::count_blocks(const std::string& import_file_path) { - streampos dummy_pos; + std::streampos dummy_pos; uint64_t dummy_height = 0; return count_blocks(import_file_path, dummy_pos, dummy_height); } @@ -441,7 +440,7 @@ uint64_t BootstrapFile::count_blocks(const std::string& import_file_path) // If seek_height is non-zero on entry, return a stream position <= this height when finished. // And return the actual height corresponding to this position. Allows the caller to locate its // starting position without having to reread the entire file again. -uint64_t BootstrapFile::count_blocks(const std::string& import_file_path, streampos &start_pos, uint64_t& seek_height) +uint64_t BootstrapFile::count_blocks(const std::string& import_file_path, std::streampos &start_pos, uint64_t& seek_height) { boost::filesystem::path raw_file_path(import_file_path); boost::system::error_code ec; diff --git a/src/blockchain_utilities/bootstrap_file.h b/src/blockchain_utilities/bootstrap_file.h index c3969a357..0926ee2e5 100644 --- a/src/blockchain_utilities/bootstrap_file.h +++ b/src/blockchain_utilities/bootstrap_file.h @@ -57,7 +57,7 @@ class BootstrapFile public: uint64_t count_bytes(std::ifstream& import_file, uint64_t blocks, uint64_t& h, bool& quit); - uint64_t count_blocks(const std::string& dir_path, streampos& start_pos, uint64_t& seek_height); + uint64_t count_blocks(const std::string& dir_path, std::streampos& start_pos, uint64_t& seek_height); uint64_t count_blocks(const std::string& dir_path); uint64_t seek_to_first_chunk(std::ifstream& import_file); |