diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-02-08 18:55:58 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-02-08 18:55:58 +0200 |
commit | 50197b62a333b51fcbd318cf2e53220a9c7d744f (patch) | |
tree | d7f2a08aa4cccbb8d9e038ff047e5ca3bea8eae2 /src/blockchain_utilities | |
parent | Merge pull request #648 (diff) | |
parent | blockchain_import: Add hard fork data for each block when verify mode is off (diff) | |
download | monero-50197b62a333b51fcbd318cf2e53220a9c7d744f.tar.xz |
Merge pull request #644
9d62c16 blockchain_import: Add hard fork data for each block when verify mode is off (warptangent)
7006b2e blockchain_utilities: Have fake_core create HardFork object (warptangent)
8f863e7 Blockchain: Optionally pass in HardFork object (warptangent)
f7e337e fake_core: Check if hard fork subdbs need reset at start (warptangent)
c657e77 blockchain_import: Add --drop-hard-fork command (warptangent)
4122439 blockchain_import: Add exception to log output (warptangent)
Diffstat (limited to 'src/blockchain_utilities')
-rw-r--r-- | src/blockchain_utilities/blockchain_import.cpp | 16 | ||||
-rw-r--r-- | src/blockchain_utilities/fake_core.h | 17 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp index 30090bd78..7eb493b6d 100644 --- a/src/blockchain_utilities/blockchain_import.cpp +++ b/src/blockchain_utilities/blockchain_import.cpp @@ -469,6 +469,9 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path, try { simple_core.add_block(b, block_size, cumulative_difficulty, coins_generated, txs); + #if !defined(BLOCKCHAIN_DB) || (BLOCKCHAIN_DB == DB_LMDB) + simple_core.m_hardfork->add(b, h-1); + #endif } catch (const std::exception& e) { @@ -500,7 +503,7 @@ int import_from_file(FakeCore& simple_core, const std::string& import_file_path, catch (const std::exception& e) { std::cout << refresh_string; - LOG_PRINT_RED_L0("exception while reading from file, height=" << h); + LOG_PRINT_RED_L0("exception while reading from file, height=" << h << ": " << e.what()); return 2; } } // while @@ -557,6 +560,7 @@ int main(int argc, char* argv[]) const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop}; 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." @@ -589,6 +593,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_cmd_only, arg_count_blocks); command_line::add_arg(desc_cmd_only, arg_pop_blocks); + command_line::add_arg(desc_cmd_only, arg_drop_hf); command_line::add_arg(desc_cmd_only, command_line::arg_help); // call add_options() directly for these arguments since @@ -761,6 +766,15 @@ int main(int argc, char* argv[]) return 0; } +#if !defined(BLOCKCHAIN_DB) || (BLOCKCHAIN_DB == DB_LMDB) + if (! vm["drop-hard-fork"].defaulted()) + { + LOG_PRINT_L0("Dropping hard fork tables..."); + simple_core.m_storage.get_db().drop_hard_fork_info(); + return 0; + } +#endif + import_from_file(simple_core, import_file_path, block_stop); #endif diff --git a/src/blockchain_utilities/fake_core.h b/src/blockchain_utilities/fake_core.h index 245d535fc..29f34026d 100644 --- a/src/blockchain_utilities/fake_core.h +++ b/src/blockchain_utilities/fake_core.h @@ -36,12 +36,21 @@ using namespace cryptonote; +namespace +{ + // NOTE: These values should match blockchain.cpp + // TODO: Refactor + const uint64_t mainnet_hard_fork_version_1_till = 1009826; + const uint64_t testnet_hard_fork_version_1_till = 624633; +} + #if !defined(BLOCKCHAIN_DB) || BLOCKCHAIN_DB == DB_LMDB struct fake_core_lmdb { Blockchain m_storage; + HardFork* m_hardfork = nullptr; tx_memory_pool m_pool; bool support_batch; bool support_add_block; @@ -75,7 +84,13 @@ struct fake_core_lmdb throw; } - m_storage.init(db, use_testnet); + db->check_hard_fork_info(); + + uint64_t hard_fork_version_1_till = use_testnet ? testnet_hard_fork_version_1_till : mainnet_hard_fork_version_1_till; + m_hardfork = new HardFork(*db, 1, hard_fork_version_1_till); + + m_storage.init(db, m_hardfork, use_testnet); + if (do_batch) m_storage.get_db().set_batch_transactions(do_batch); support_batch = true; |