Skip to content

Commit

Permalink
GH-3 Add better log message
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 18, 2024
1 parent 51503c4 commit b694aad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libraries/chain/include/eosio/chain/vote_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class vote_processor_t {

using vote_index_type = boost::multi_index_container< vote,
indexed_by<
ordered_non_unique< tag<by_block_num>, const_mem_fun<vote, block_num_type, &vote::block_num>, std::greater<> >,
ordered_non_unique< tag<by_block_num>, const_mem_fun<vote, block_num_type, &vote::block_num>, std::greater<> >, // decending
ordered_non_unique< tag<by_connection>, member<vote, uint32_t, &vote::connection_id> >,
ordered_non_unique< tag<by_last_received>, member<vote, fc::time_point, &vote::received> >
>
Expand Down Expand Up @@ -213,13 +213,14 @@ class vote_processor_t {
std::unique_lock g(mtx);
if (reset_num_messages)
num_messages.clear();
if (++num_messages[connection_id] > max_votes_per_connection) {
if (auto& num_msgs = ++num_messages[connection_id]; num_msgs > max_votes_per_connection) {
remove_connection(connection_id);
g.unlock();
// drop, too many from this connection to process, consider connection invalid
// don't clear num_messages[connection_id] so we keep reporting max_exceeded until index is drained

elog("Exceeded max votes per connection for ${c}", ("c", connection_id));
ilog("Exceeded max votes per connection ${n} > ${max} for ${c}",
("n", num_msgs)("max", max_votes_per_connection)("c", connection_id));
emit(connection_id, vote_status::max_exceeded, msg);
} else {
block_state_ptr bsp = get_block(msg->block_id, g);
Expand Down

0 comments on commit b694aad

Please sign in to comment.