Refactored consensus into 3 rounds. (#144)

* Refactored consensus into 3 stages and removed stage 0.
* Consensus threshold calculation improvements.
* Refactored candidate user input processing.
* Renamed proposal sent timestamp field.
* Introduced comm_session display name.
This commit is contained in:
Ravin Perera
2020-11-07 15:01:01 +05:30
committed by GitHub
parent 51173e37f2
commit ba0cae019d
17 changed files with 568 additions and 516 deletions

View File

@@ -17,11 +17,11 @@ int user_session_handler::on_connect(comm::comm_session &session) const
{
if (conf::cfg.pubmaxcons > 0 && ctx.users.size() >= conf::cfg.pubmaxcons)
{
LOG_DEBUG << "Max user connections reached. Dropped connection " << session.uniqueid.substr(0, 10);
LOG_DEBUG << "Max user connections reached. Dropped connection " << session.display_name();
return -1;
}
LOG_DEBUG << "User client connected " << session.uniqueid.substr(0, 10);
LOG_DEBUG << "User client connected " << session.display_name();
// As soon as a user connects, we issue them a challenge message. We remember the
// challenge we issued and later verify the user's response with it.
@@ -61,13 +61,13 @@ int user_session_handler::on_message(comm::comm_session &session, std::string_vi
if (handle_user_message(user, message) != 0)
{
session.increment_metric(comm::SESSION_THRESHOLDS::MAX_BADMSGS_PER_MINUTE, 1);
LOG_DEBUG << "Bad message from user " << session.uniqueid.substr(0, 10);
LOG_DEBUG << "Bad message from user " << session.display_name();
}
}
else
{
session.increment_metric(comm::SESSION_THRESHOLDS::MAX_BADMSGS_PER_MINUTE, 1);
LOG_DEBUG << "User session id not found: " << session.uniqueid.substr(0, 10);
LOG_DEBUG << "User session id not found: " << session.display_name();
}
return 0;
@@ -75,7 +75,7 @@ int user_session_handler::on_message(comm::comm_session &session, std::string_vi
// If for any reason we reach this point, we should drop the connection because none of the
// valid cases match.
LOG_DEBUG << "Dropping the user connection " << session.uniqueid.substr(0, 10);
LOG_DEBUG << "Dropping the user connection " << session.display_name();
corebill::report_violation(session.address);
return -1;
}