| 255 | } |
| 256 | |
| 257 | bool LegacyBlockChainWriter::export_blockchain2(const std::string &index_file_name, const std::string &item_file_name, |
| 258 | const BlockChainState &block_chain, Height max_height) { |
| 259 | auto idea_start = std::chrono::high_resolution_clock::now(); |
| 260 | std::cout << "Start exporting blocks" << std::endl; |
| 261 | LegacyBlockChainWriter writer(index_file_name, item_file_name, block_chain.get_tip_height() + 1); |
| 262 | for (Height ha = 0; ha != block_chain.get_tip_height() + 1; ++ha) { |
| 263 | if (ha >= max_height) |
| 264 | break; |
| 265 | Hash bid{}; |
| 266 | BinaryArray block_data; |
| 267 | RawBlock raw_block; |
| 268 | if (!block_chain.get_chain(ha, &bid) || !block_chain.get_block(bid, &block_data, &raw_block)) |
| 269 | throw std::runtime_error("block_chain.get_block failed"); |
| 270 | writer.write_block(raw_block); |
| 271 | if (ha % 10000 == 0) |
| 272 | std::cout << "Exporting block " << ha << "/" << block_chain.get_tip_height() << std::endl; |
| 273 | } |
| 274 | auto idea_ms = |
| 275 | std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - idea_start); |
| 276 | std::cout << "Last exported block " << block_chain.get_tip_height() << " seconds=" << double(idea_ms.count()) / 1000 |
| 277 | << std::endl; |
| 278 | return true; |
| 279 | } |
nothing calls this directly
no test coverage detected