Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] Backport: [statehist] Ship logs reduction / optimization #620

Merged
merged 6 commits into from
Jul 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions plugins/state_history_plugin/state_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,29 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
}
++current_request->start_block_num;
}
fc_ilog(_log, "pushing result {\"head\":{\"block_num\":${head}},\"last_irreversible\":{\"block_num\":${last_irr}},\"this_block\":{\"block_num\":${this_block}}} to send queue",
("head", result.head.block_num) ("last_irr", result.last_irreversible.block_num)("this_block", result.this_block->block_num));

auto& block_num = current_request->start_block_num;
auto get_blk = [&chain, block_num, block_state]() -> signed_block_ptr {
try {
if (block_state && block_state->block_num == block_num)
return block_state->block;
return chain.fetch_block_by_number(block_num);
} catch (...) {
return {};
}
};
auto block = get_blk();

// during syncing if block is older than 5 min, log every 1000th block
bool fresh_block = block && fc::time_point::now() - block->timestamp < fc::minutes(5);
if( fresh_block || (result.this_block && result.this_block->block_num % 1000 == 0) ) {
fc_ilog(_log, "pushing result "
"{\"head\":{\"block_num\":${head}},\"last_irreversible\":{\"block_num\":${last_irr}},\"this_block\":{"
"\"block_num\":${this_block}}} to send queue",
("head", result.head.block_num)("last_irr", result.last_irreversible.block_num)(
"this_block", result.this_block ? result.this_block->block_num : fc::variant()));
}

send(std::move(result));
--current_request->max_messages_in_flight;
need_to_send_update = current_request->start_block_num <= current &&
Expand Down