aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-01 10:09:35 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-12 16:13:46 +0000
commitb278b83860da5eaaa122c219ad8c63f641e41cd3 (patch)
tree5aa3fb8e70e94239c524f86e923c5ed49a78fa03 /src/cryptonote_core/cryptonote_core.cpp
parent0dddfeacc982ad208808e3a828163837fc4aba38 (diff)
downloadmonzero-core-b278b83860da5eaaa122c219ad8c63f641e41cd3.tar.gz
monzero-core-b278b83860da5eaaa122c219ad8c63f641e41cd3.tar.xz
monzero-core-b278b83860da5eaaa122c219ad8c63f641e41cd3.zip
core: sync database based on bytes added, not blocks added
Blocks have a very wide range, whereas actual size is the relevant quantity to consider when syncing
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp28
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 = {