Already submitted input detection. (#170)

* Added same nonce/sig for input comparison.
* Added status response withholding for already submitted inputs.
This commit is contained in:
Ravin Perera
2020-11-26 23:27:40 +05:30
committed by GitHub
parent d476f787a7
commit 4de1bb2393
5 changed files with 49 additions and 27 deletions

View File

@@ -474,15 +474,20 @@ namespace consensus
for (auto &resp : user_responses)
{
// resp: 0=protocl, 1=msg sig, 2=reject reason.
msg::usrmsg::usrmsg_parser parser(std::get<0>(resp));
const std::string &msg_sig = std::get<1>(resp);
const char *reject_reason = std::get<2>(resp);
usr::send_input_status(parser,
user_itr->second.session,
reject_reason == NULL ? msg::usrmsg::STATUS_ACCEPTED : msg::usrmsg::STATUS_REJECTED,
reject_reason == NULL ? "" : reject_reason,
msg_sig);
// We are not sending any status response for 'already submitted' inputs. This is because the user
// would have gotten the proper status response during first submission.
if (reject_reason != msg::usrmsg::REASON_ALREADY_SUBMITTED)
{
msg::usrmsg::usrmsg_parser parser(std::get<0>(resp));
const std::string &msg_sig = std::get<1>(resp);
usr::send_input_status(parser,
user_itr->second.session,
reject_reason == NULL ? msg::usrmsg::STATUS_ACCEPTED : msg::usrmsg::STATUS_REJECTED,
reject_reason == NULL ? "" : reject_reason,
msg_sig);
}
}
}
}