🐎 contains check for SendFunds before unique grabbed

This commit is contained in:
EntireTwix 2021-06-12 20:56:04 -07:00
parent 8f47c12450
commit 3279835696

View file

@ -90,6 +90,12 @@ int_fast8_t Bank::SendFunds(const std::string &a_name, const std::string &b_name
{ {
return ErrorResponse::InvalidRequest; return ErrorResponse::InvalidRequest;
} }
//as first modify_if checks a_name and grabs unique lock
if (!Contains(b_name))
{
return ErrorResponse::UserNotFound;
}
int_fast8_t state = false; int_fast8_t state = false;
{ {
std::shared_lock<std::shared_mutex> lock{send_funds_l}; //because SendFunds requires 3 locking operations std::shared_lock<std::shared_mutex> lock{send_funds_l}; //because SendFunds requires 3 locking operations