Skip to content

Commit

Permalink
Revert ifs on Add/Sub
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Feb 23, 2023
1 parent 4d931e3 commit 6849d6e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/masternodes/balances.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ struct CBalances {
return Res::Ok();
}
auto current = CTokenAmount{amount.nTokenId, balances[amount.nTokenId]};
Require(current.Add(amount.nValue));
if (auto res = current.Add(amount.nValue); !res) {
return res;
}
if (current.nValue == 0) {
balances.erase(amount.nTokenId);
} else {
Expand All @@ -32,7 +34,9 @@ struct CBalances {
return Res::Ok();
}
auto current = CTokenAmount{amount.nTokenId, balances[amount.nTokenId]};
Require(current.Sub(amount.nValue));
if (auto res = current.Sub(amount.nValue); !res) {
return res;
}

if (current.nValue == 0) {
balances.erase(amount.nTokenId);
Expand Down

0 comments on commit 6849d6e

Please sign in to comment.