diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-07-08 17:59:39 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-07 09:33:14 +0100 |
commit | 90df52e12f4fbf40cb475670f1d325e03abbf327 (patch) | |
tree | f81e8e2ba20fdaeb722ad6c8eea1420d31fba227 | |
parent | cryptonote_protocol: avoid spurious SYNCHRONIZED OK messages (diff) | |
download | monero-90df52e12f4fbf40cb475670f1d325e03abbf327.tar.xz |
cryptonote_protocol: light cleanup
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp | 4 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 31 |
2 files changed, 9 insertions, 26 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp index e31276031..137dbacfc 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp +++ b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp @@ -120,10 +120,6 @@ cryptonote_protocol_handler_base::~cryptonote_protocol_handler_base() { } void cryptonote_protocol_handler_base::handler_request_blocks_history(std::list<crypto::hash>& ids) { - using namespace epee::net_utils; - MDEBUG("### ~~~RRRR~~~~ ### sending request (type 2), limit = " << ids.size()); - MDEBUG("RATE LIMIT NOT IMPLEMENTED HERE YET (download at unlimited speed?)"); - // TODO } void cryptonote_protocol_handler_base::handler_response_blocks_now(size_t packet_size) { diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index c93a09a85..da250714e 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -804,21 +804,15 @@ namespace cryptonote template<class t_core> - double t_cryptonote_protocol_handler<t_core>::get_avg_block_size() { - // return m_core.get_blockchain_storage().get_avg_block_size(count); // this does not count too well the actuall network-size of data we need to download - + double t_cryptonote_protocol_handler<t_core>::get_avg_block_size() + { CRITICAL_REGION_LOCAL(m_buffer_mutex); - double avg = 0; - if (m_avg_buffer.size() == 0) { - _warn("m_avg_buffer.size() == 0"); + if (m_avg_buffer.empty()) { + MWARNING("m_avg_buffer.size() == 0"); return 500; } - - const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option - long int dbg_repeat=0; - do { - for (auto element : m_avg_buffer) avg += element; - } while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one + double avg = 0; + for (const auto &element : m_avg_buffer) avg += element; return avg / m_avg_buffer.size(); } @@ -832,30 +826,23 @@ namespace cryptonote // calculate size of request size_t size = 0; - for (auto element : arg.txs) size += element.size(); + for (const auto &element : arg.txs) size += element.size(); size_t blocks_size = 0; - for (auto element : arg.blocks) { + for (const auto &element : arg.blocks) { blocks_size += element.block.size(); for (const auto &tx : element.txs) blocks_size += tx.size(); } size += blocks_size; - for (auto element : arg.missed_ids) + for (const auto &element : arg.missed_ids) size += sizeof(element.data); size += sizeof(arg.current_blockchain_height); { CRITICAL_REGION_LOCAL(m_buffer_mutex); m_avg_buffer.push_back(size); - - const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option - long int dbg_repeat=0; - do { - m_avg_buffer.push_back(666); // a test value - m_avg_buffer.erase_end(1); - } while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one } MDEBUG(context << " downloaded " << size << " bytes worth of blocks"); |