diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2018-08-22 20:43:51 -0500 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2018-08-22 20:43:51 -0500 |
| commit | 4a4ea78ecd753e1ab6be7309ab549417d8d84d6d (patch) | |
| tree | dab9aa6e74b8d9419f621d246b9399e7f6390742 /src/cryptonote_core/cryptonote_core.cpp | |
| parent | 6e8e4fb3b72574f3ff4423abe12b0064c07cc930 (diff) | |
| parent | b278b83860da5eaaa122c219ad8c63f641e41cd3 (diff) | |
| download | monzero-core-4a4ea78ecd753e1ab6be7309ab549417d8d84d6d.tar.gz monzero-core-4a4ea78ecd753e1ab6be7309ab549417d8d84d6d.tar.xz monzero-core-4a4ea78ecd753e1ab6be7309ab549417d8d84d6d.zip | |
Merge pull request #4204
b278b83 core: sync database based on bytes added, not blocks added (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
| -rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 18490c65e..d0db38799 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -439,9 +439,10 @@ namespace cryptonote MGINFO("Loading blockchain from folder " << folder.string() << " ..."); const std::string filename = folder.string(); - // default to fast:async:1 + // default to fast:async:1 if overridden blockchain_db_sync_mode sync_mode = db_defaultsync; - uint64_t blocks_per_sync = 1; + bool sync_on_blocks = true; + uint64_t sync_threshold = 1; if (m_nettype == FAKECHAIN) { @@ -491,7 +492,7 @@ namespace cryptonote else if(options[0] == "fastest") { db_flags = DBF_FASTEST; - blocks_per_sync = 1000; // default to fastest:async:1000 + sync_threshold = 1000; // default to fastest:async:1000 sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async; } else @@ -509,9 +510,22 @@ namespace cryptonote if(options.size() >= 3 && !safemode) { char *endptr; - uint64_t bps = strtoull(options[2].c_str(), &endptr, 0); - if (*endptr == '\0') - blocks_per_sync = bps; + uint64_t threshold = strtoull(options[2].c_str(), &endptr, 0); + if (*endptr == '\0' || !strcmp(endptr, "blocks")) + { + sync_on_blocks = true; + sync_threshold = threshold; + } + else if (!strcmp(endptr, "bytes")) + { + sync_on_blocks = false; + sync_threshold = threshold; + } + else + { + LOG_ERROR("Invalid db sync mode: " << options[2]); + return false; + } } if (db_salvage) @@ -528,7 +542,7 @@ namespace cryptonote } m_blockchain_storage.set_user_options(blocks_threads, - blocks_per_sync, sync_mode, fast_sync); + sync_on_blocks, sync_threshold, sync_mode, fast_sync); const std::pair<uint8_t, uint64_t> regtest_hard_forks[3] = {std::make_pair(1, 0), std::make_pair(Blockchain::get_hard_fork_heights(MAINNET).back().version, 1), std::make_pair(0, 0)}; const cryptonote::test_options regtest_test_options = { |
