aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-09-24 17:00:19 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-09-24 17:00:19 +0100
commit5e3e362c854dd59c5399dbf6fe1a5675826f6732 (patch)
treed81eef8351868e035e9bb864c8d744b55a0fba9d /src
parentMerge pull request #1102 (diff)
downloadmonero-5e3e362c854dd59c5399dbf6fe1a5675826f6732.tar.xz
core: make the sync chunk block count overridable
Diffstat (limited to 'src')
-rw-r--r--src/common/command_line.cpp6
-rw-r--r--src/common/command_line.h1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp5
-rw-r--r--src/cryptonote_core/cryptonote_core.h9
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl4
5 files changed, 23 insertions, 2 deletions
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index fc096abe5..b3f488447 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -30,6 +30,7 @@
#include "command_line.h"
#include "string_tools.h"
+#include "cryptonote_config.h"
namespace command_line
{
@@ -92,4 +93,9 @@ namespace command_line
, "Show time-stats when processing blocks/txs and disk synchronization."
, 0
};
+ const command_line::arg_descriptor<size_t> arg_block_sync_size = {
+ "block-sync-size"
+ , "How many blocks to sync at once during chain synchronization."
+ , BLOCKS_SYNCHRONIZING_DEFAULT_COUNT
+ };
}
diff --git a/src/common/command_line.h b/src/common/command_line.h
index 731b8b0bb..0ea749168 100644
--- a/src/common/command_line.h
+++ b/src/common/command_line.h
@@ -216,4 +216,5 @@ namespace command_line
extern const arg_descriptor<uint64_t> arg_prep_blocks_threads;
extern const arg_descriptor<uint64_t> arg_db_auto_remove_logs;
extern const arg_descriptor<uint64_t> arg_show_time_stats;
+ extern const arg_descriptor<size_t> arg_block_sync_size;
}
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index c289f297b..4abf6a898 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -142,6 +142,7 @@ namespace cryptonote
command_line::add_arg(desc, command_line::arg_db_sync_mode);
command_line::add_arg(desc, command_line::arg_show_time_stats);
command_line::add_arg(desc, command_line::arg_db_auto_remove_logs);
+ command_line::add_arg(desc, command_line::arg_block_sync_size);
}
//-----------------------------------------------------------------------------------------------
bool core::handle_command_line(const boost::program_options::variables_map& vm)
@@ -403,6 +404,10 @@ namespace cryptonote
m_blockchain_storage.set_show_time_stats(show_time_stats);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
+ block_sync_size = command_line::get_arg(vm, command_line::arg_block_sync_size);
+ if (block_sync_size == 0)
+ block_sync_size = BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
+
// load json & DNS checkpoints, and verify them
// with respect to what blocks we already have
CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints.");
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index d16bd6553..97abf3271 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -611,6 +611,13 @@ namespace cryptonote
*/
bool are_key_images_spent(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
+ /**
+ * @brief get the number of blocks to sync in one go
+ *
+ * @return the number of blocks to sync in one go
+ */
+ size_t get_block_sync_size() const { return block_sync_size; }
+
private:
/**
@@ -798,6 +805,8 @@ namespace cryptonote
std::atomic_flag m_checkpoints_updating; //!< set if checkpoints are currently updating to avoid multiple threads attempting to update at once
boost::interprocess::file_lock db_lock; //!< a lock object for a file lock in the db directory
+
+ size_t block_sync_size;
};
}
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index f16dad281..6dfc9fbc5 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -650,9 +650,9 @@ namespace cryptonote
size_t count = 0;
auto it = context.m_needed_objects.begin();
- size_t count_limit = BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
+ const size_t count_limit = m_core.get_block_sync_size();
_note_c("net/req-calc" , "Setting count_limit: " << count_limit);
- while(it != context.m_needed_objects.end() && count < BLOCKS_SYNCHRONIZING_DEFAULT_COUNT)
+ while(it != context.m_needed_objects.end() && count < count_limit)
{
if( !(check_having_blocks && m_core.have_block(*it)))
{