Switched user input nonce from string to uint64. (#286)

This commit is contained in:
Ravin Perera
2021-04-11 14:51:57 +05:30
committed by GitHub
parent 3941f5f6c6
commit 370e03fe84
24 changed files with 72 additions and 53 deletions

View File

@@ -15,7 +15,7 @@ namespace usr
* 1 if nonce has expired.
* 2 if message with same nonce/sig has already been submitted.
*/
int input_nonce_map::check(const std::string &pubkey, const std::string &nonce, const std::string &sig, const uint64_t &max_ledger_seq_no, const bool no_add)
int input_nonce_map::check(const std::string &pubkey, const uint64_t &nonce, const std::string &sig, const uint64_t &max_ledger_seq_no, const bool no_add)
{
int result = 0;
@@ -25,11 +25,11 @@ namespace usr
{
result = 0;
if (!no_add)
nonce_map.emplace(pubkey, std::tuple<std::string, std::string, uint64_t>(nonce, sig, max_ledger_seq_no));
nonce_map.emplace(pubkey, std::tuple<uint64_t, std::string, uint64_t>(nonce, sig, max_ledger_seq_no));
}
else
{
const std::string &existing_nonce = std::get<0>(itr->second);
const uint64_t &existing_nonce = std::get<0>(itr->second);
const uint64_t expire_lcl_seq_no = std::get<2>(itr->second);
// Check if previous nonce has already expired or it is less than new nonce.