aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-08-16 21:19:53 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-08-17 13:11:52 +0100
commit5a283078ec3cf276dd085219f4ead51ced969224 (patch)
treef3b1d4a2ea69fd13941127e7d657ffd731b0429f
parentcryptonote_protocol: kick idle synchronizing peers (diff)
downloadmonero-5a283078ec3cf276dd085219f4ead51ced969224.tar.xz
cryptonote_protocol: large block sync size before v4
-rw-r--r--src/common/command_line.cpp4
-rw-r--r--src/cryptonote_config.h1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp12
-rw-r--r--src/cryptonote_core/cryptonote_core.h2
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl2
-rw-r--r--tests/core_proxy/core_proxy.h2
-rw-r--r--tests/unit_tests/ban.cpp2
7 files changed, 17 insertions, 8 deletions
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index 5f60bef89..925d8ff3b 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -129,8 +129,8 @@ namespace command_line
};
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
+ , "How many blocks to sync at once during chain synchronization (0 = adaptive)."
+ , 0
};
const command_line::arg_descriptor<std::string> arg_check_updates = {
"check-updates"
diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h
index fd45c0822..8ff01cf8b 100644
--- a/src/cryptonote_config.h
+++ b/src/cryptonote_config.h
@@ -89,6 +89,7 @@
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
+#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
#define CRYPTONOTE_PROTOCOL_HOP_RELAX_COUNT 3 //value of hop, after which we use only announce of new block
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index ac2d3023a..046b0eca0 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -421,8 +421,6 @@ namespace cryptonote
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;
MGINFO("Loading checkpoints");
@@ -788,6 +786,16 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
+ size_t core::get_block_sync_size(uint64_t height) const
+ {
+ static const uint64_t quick_height = m_testnet ? 801219 : 1220516;
+ if (block_sync_size > 0)
+ return block_sync_size;
+ if (height >= quick_height)
+ return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
+ return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4;
+ }
+ //-----------------------------------------------------------------------------------------------
std::pair<uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const size_t count)
{
uint64_t emission_amount = 0;
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 63d3cd16d..982d67169 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -691,7 +691,7 @@ namespace cryptonote
*
* @return the number of blocks to sync in one go
*/
- size_t get_block_sync_size() const { return block_sync_size; }
+ size_t get_block_sync_size(uint64_t height) const;
/**
* @brief get the sum of coinbase tx amounts between blocks
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index c33670a05..60cce4594 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -1286,7 +1286,7 @@ skip:
NOTIFY_REQUEST_GET_OBJECTS::request req;
bool is_next = false;
size_t count = 0;
- const size_t count_limit = m_core.get_block_sync_size();
+ const size_t count_limit = m_core.get_block_sync_size(m_core.get_current_blockchain_height());
std::pair<uint64_t, uint64_t> span = std::make_pair(0, 0);
if (force_next_span)
{
diff --git a/tests/core_proxy/core_proxy.h b/tests/core_proxy/core_proxy.h
index b7d5725f0..6df7e7fc9 100644
--- a/tests/core_proxy/core_proxy.h
+++ b/tests/core_proxy/core_proxy.h
@@ -88,7 +88,7 @@ namespace tests
bool prepare_handle_incoming_blocks(const std::list<cryptonote::block_complete_entry> &blocks) { return true; }
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
uint64_t get_target_blockchain_height() const { return 1; }
- size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
+ size_t get_block_sync_size(uint64_t height) const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
bool get_testnet() const { return false; }
bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx_blob) const { return false; }
diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp
index 6fc8b83dd..6a1a37fe3 100644
--- a/tests/unit_tests/ban.cpp
+++ b/tests/unit_tests/ban.cpp
@@ -65,7 +65,7 @@ public:
bool prepare_handle_incoming_blocks(const std::list<cryptonote::block_complete_entry> &blocks) { return true; }
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
uint64_t get_target_blockchain_height() const { return 1; }
- size_t get_block_sync_size() const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
+ size_t get_block_sync_size(uint64_t height) const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
bool get_testnet() const { return false; }
bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx_blob) const { return false; }