Skip to content

Commit

Permalink
src: fix issues
Browse files Browse the repository at this point in the history
Co-authored-by: nahuhh
  • Loading branch information
0xFFFC0000 committed Feb 24, 2025
1 parent 5459934 commit 03bcd6f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 3 additions & 4 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@
#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 BLOCKS_SYNCHRONIZING_MAX_COUNT 2048 //must be a power of 2, greater than 128, equal to SEEDHASH_EPOCH_BLOCKS
#define BLOCKS_MEDIAN_WINDOW 100 //by default, compute median weights of last 100 blocks
#define BATCH_MAX_WEIGHT 20 //by default, maximum size of batch in [mB]
#define BATCH_MAX_ALLOWED_WEIGHT 50 //maximum allowed size of batch in [mB]
#define BLOCKS_HUGE_THRESHOLD_SIZE ((BATCH_MAX_WEIGHT * 1000000) / 2) //blocks that we consider huge [B]
#define BATCH_MAX_WEIGHT 10 //by default, maximum size of batch in [mB]
#define BATCH_MAX_ALLOWED_WEIGHT 50 //maximum allowed size of batch in [mB]
#define BLOCKS_MEDIAN_WINDOW CRYPTONOTE_REWARD_BLOCKS_WINDOW //compute median weights of last 100 blocks

#define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) //seconds, three days
#define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 //seconds, one week
Expand Down
16 changes: 9 additions & 7 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace cryptonote
};
static const command_line::arg_descriptor<size_t> arg_batch_max_weight = {
"batch-max-weight"
, "How many megabytes to sync in one batch during chain synchronization, default is 20 max"
, "How many megabytes to sync in one batch during chain synchronization, default is 10"
, (BATCH_MAX_WEIGHT)
};
static const command_line::arg_descriptor<std::string> arg_check_updates = {
Expand Down Expand Up @@ -706,6 +706,11 @@ namespace cryptonote
batch_max_weight = BATCH_MAX_ALLOWED_WEIGHT;
}

if ((batch_max_weight == 0)) {
MINFO("Using default --batch-max-weight of " << BATCH_MAX_WEIGHT << " [mB]");
batch_max_weight = BATCH_MAX_WEIGHT;
}

batch_max_weight *= 1000000; // transfer it to byte.

MGINFO("Loading checkpoints");
Expand Down Expand Up @@ -1245,17 +1250,14 @@ namespace cryptonote
<< " blocks median size is " << median_weight
<< " bytes and the max average blocksize in the queue is " << average_blocksize_of_biggest_batch << " bytes");
uint64_t projected_blocksize = (average_blocksize_of_biggest_batch > median_weight) ? average_blocksize_of_biggest_batch : median_weight;
uint64_t blocks_huge_threshold = (batch_max_weight / 2);
if ((projected_blocksize * BLOCKS_MEDIAN_WINDOW) < batch_max_weight) {
res = BLOCKS_MEDIAN_WINDOW;
MINFO("blocks are tiny, " << projected_blocksize << " bytes, sync " << res << " blocks in next batch");
}
else if (projected_blocksize >= batch_max_weight) {
res = 1;
MINFO("blocks are projected to surpass " << batch_max_weight << " bytes, syncing just a single block in next batch");
}
else if (projected_blocksize > BLOCKS_HUGE_THRESHOLD_SIZE) {
else if (projected_blocksize >= blocks_huge_threshold) {
res = 1;
MINFO("blocks are huge, sync just a single block in next batch");
MINFO("blocks are projected to surpass 50% of " << batch_max_weight << " bytes, syncing just a single block in next batch");
}
else {
res = batch_max_weight / projected_blocksize;
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_protocol/cryptonote_protocol_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace cryptonote
void log_connections();
std::list<connection_info> get_connections();
const block_queue &get_block_queue() const { return m_block_queue; }
const std::uint64_t max_average_of_blocksize_in_queue() {
std::uint64_t max_average_of_blocksize_in_queue() {
std::vector<std::uint64_t> average_blocksize{0};
m_block_queue.foreach([&](const cryptonote::block_queue::span &span) {
average_blocksize.push_back(span.size / span.nblocks);
Expand Down

0 comments on commit 03bcd6f

Please sign in to comment.