diff options
author | warptangent <warptangent@inbox.com> | 2015-03-22 10:57:21 -0700 |
---|---|---|
committer | warptangent <warptangent@inbox.com> | 2015-03-22 15:45:37 -0700 |
commit | 7476d2e253b50ade052cc62bdac78cd190b11190 (patch) | |
tree | 850d6dca55b23908993e3e63753297ec1c999246 | |
parent | Update Blockchain::get_db() to return reference instead of pointer (diff) | |
download | monero-7476d2e253b50ade052cc62bdac78cd190b11190.tar.xz |
blockchain_export: show progress during export
-rw-r--r-- | src/blockchain_converter/blockchain_export.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/blockchain_converter/blockchain_export.cpp b/src/blockchain_converter/blockchain_export.cpp index f0fd44a4f..4587ce925 100644 --- a/src/blockchain_converter/blockchain_export.cpp +++ b/src/blockchain_converter/blockchain_export.cpp @@ -239,14 +239,16 @@ bool BlockchainExport::BlockchainExport::close() #if SOURCE_DB == DB_MEMORY -bool BlockchainExport::store_blockchain_raw(blockchain_storage* _blockchain_storage, tx_memory_pool* _tx_pool, boost::filesystem::path& output_dir, uint64_t use_block_height) +bool BlockchainExport::store_blockchain_raw(blockchain_storage* _blockchain_storage, tx_memory_pool* _tx_pool, boost::filesystem::path& output_dir, uint64_t requested_block_height) #else -bool BlockchainExport::store_blockchain_raw(Blockchain* _blockchain_storage, tx_memory_pool* _tx_pool, boost::filesystem::path& output_dir, uint64_t use_block_height) +bool BlockchainExport::store_blockchain_raw(Blockchain* _blockchain_storage, tx_memory_pool* _tx_pool, boost::filesystem::path& output_dir, uint64_t requested_block_height) #endif { - uint64_t use_block_height2 = 0; + uint64_t block_height = 0; m_blockchain_storage = _blockchain_storage; m_tx_pool = _tx_pool; + uint64_t progress_interval = 100; + std::string refresh_string = "\r \r"; LOG_PRINT_L0("Storing blocks raw data..."); if (!BlockchainExport::open(output_dir)) { @@ -255,15 +257,15 @@ bool BlockchainExport::store_blockchain_raw(Blockchain* _blockchain_storage, tx_ } block b; LOG_PRINT_L0("source blockchain height: " << m_blockchain_storage->get_current_blockchain_height()); - LOG_PRINT_L0("requested block height: " << use_block_height); - if ((use_block_height > 0) && (use_block_height < m_blockchain_storage->get_current_blockchain_height())) - use_block_height2 = use_block_height; + LOG_PRINT_L0("requested block height: " << requested_block_height); + if ((requested_block_height > 0) && (requested_block_height < m_blockchain_storage->get_current_blockchain_height())) + block_height = requested_block_height; else { - use_block_height2 = m_blockchain_storage->get_current_blockchain_height(); - LOG_PRINT_L0("using block height: " << use_block_height2); + block_height = m_blockchain_storage->get_current_blockchain_height(); + LOG_PRINT_L0("Using block height of source blockchain: " << block_height); } - for (height=0; height < use_block_height2; ++height) + for (height=0; height < block_height; ++height) { crypto::hash hash = m_blockchain_storage->get_block_id_by_height(height); m_blockchain_storage->get_block_by_hash(hash, b); @@ -271,11 +273,17 @@ bool BlockchainExport::store_blockchain_raw(Blockchain* _blockchain_storage, tx_ if (height % NUM_BLOCKS_PER_CHUNK == 0) { flush_chunk(); } + if (height % progress_interval == 0) { + std::cout << refresh_string; + std::cout << "height " << height << "/" << block_height << std::flush; + } } if (height % NUM_BLOCKS_PER_CHUNK != 0) { flush_chunk(); } + std::cout << refresh_string; + std::cout << "height " << height << "/" << block_height << ENDL; LOG_PRINT_L0("longest chunk was " << max_chunk << " bytes"); return BlockchainExport::close(); |