mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
cryptonote_protocol: light cleanup
This commit is contained in:
parent
84e23156ac
commit
90df52e12f
2 changed files with 9 additions and 26 deletions
|
@ -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) {
|
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) {
|
void cryptonote_protocol_handler_base::handler_response_blocks_now(size_t packet_size) {
|
||||||
|
|
|
@ -804,21 +804,15 @@ namespace cryptonote
|
||||||
|
|
||||||
|
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
double t_cryptonote_protocol_handler<t_core>::get_avg_block_size() {
|
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
|
{
|
||||||
|
|
||||||
CRITICAL_REGION_LOCAL(m_buffer_mutex);
|
CRITICAL_REGION_LOCAL(m_buffer_mutex);
|
||||||
double avg = 0;
|
if (m_avg_buffer.empty()) {
|
||||||
if (m_avg_buffer.size() == 0) {
|
MWARNING("m_avg_buffer.size() == 0");
|
||||||
_warn("m_avg_buffer.size() == 0");
|
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
double avg = 0;
|
||||||
const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option
|
for (const auto &element : m_avg_buffer) avg += element;
|
||||||
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
|
|
||||||
return avg / m_avg_buffer.size();
|
return avg / m_avg_buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,30 +826,23 @@ namespace cryptonote
|
||||||
|
|
||||||
// calculate size of request
|
// calculate size of request
|
||||||
size_t size = 0;
|
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;
|
size_t blocks_size = 0;
|
||||||
for (auto element : arg.blocks) {
|
for (const auto &element : arg.blocks) {
|
||||||
blocks_size += element.block.size();
|
blocks_size += element.block.size();
|
||||||
for (const auto &tx : element.txs)
|
for (const auto &tx : element.txs)
|
||||||
blocks_size += tx.size();
|
blocks_size += tx.size();
|
||||||
}
|
}
|
||||||
size += blocks_size;
|
size += blocks_size;
|
||||||
|
|
||||||
for (auto element : arg.missed_ids)
|
for (const auto &element : arg.missed_ids)
|
||||||
size += sizeof(element.data);
|
size += sizeof(element.data);
|
||||||
|
|
||||||
size += sizeof(arg.current_blockchain_height);
|
size += sizeof(arg.current_blockchain_height);
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_buffer_mutex);
|
CRITICAL_REGION_LOCAL(m_buffer_mutex);
|
||||||
m_avg_buffer.push_back(size);
|
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");
|
MDEBUG(context << " downloaded " << size << " bytes worth of blocks");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue