Given the code below, when I compile the code with Remix it says the function processBandPayments() can be marked as view. This concerns me greatly since in my mind, the code is changing state by altering the content of one or the other storage variables; in this case the claims or escrow storage variable.
So either this is a Solc/Remix bug (doubtful) or my code doesn't do what I think it does and doesn't really record payments or escrow assignments to the blockchain. Can anyone shed some light on this?
// The map that maps a game ID to a specific game.
mapping(uint256 => structGame) public s_mapGameIdToGame;
// The map that maps a request nonce to a game ID.
mapping (address => uint256) public s_mapRequestNonceToGameId;
// The map that tracks how much Ether is due to a particular address, whether that
// address is a player or a band.
mapping (address => uint256) public s_mapAddressToClaimAmount;
// The map that tracks how much Ether is due to a paritcular owner ID. This is the
// "escrow" storage.
mapping (bytes32 => uint256) public s_mapOwnerIdToEscrowAmount;
// The round of each play in a game is stored here.
mapping (uint256 => structGameRoundResults[]) public s_mapGameIdToGameResults;
/**
* @notice Process the payments to the band using the results of the game given
* to us earlier by multiple calls to addGameRoundResult().
*
* NOTE: If an address is not found in the band addresses array, the amount due that
* band is stored in the escrow map instead of the claims map.
*
* param _perBandPayment - The amount to pay each band.
*/
function processBandPayments(
uint256 _gameId,
uint256 _perBandPayment
)
private
onlyIfValidGameId(_gameId) onlyIfPlayingState(_gameId) {
// We should have at least one game round result or something is
// very wrong.
require(s_mapGameIdToGameResults[_gameId].length > 0, "(processBandPayments) The game round results array is empty.");
// If the band donation percentage is 0, then this method should not have been called.
require(_perBandPayment > 0, "(processBandPayments) The payment for each band is 0.");
// Process each band payment by iterating the game round results.
for (uint i = 0; i < s_mapGameIdToGameResults[_gameId].length; i++)
{
require(s_mapGameIdToGameResults[_gameId][i].ownerId.length > 0, "(processBandPayments) An owner ID was not set.");
// Do we have a band address?
if (s_mapGameIdToGameResults[_gameId][i].bandAddr == address(0)) {
// No. Aggregate the payment amount in escrow.
s_mapOwnerIdToEscrowAmount[s_mapGameIdToGameResults[_gameId][i].ownerId].add(_perBandPayment);
}
else {
// Yes. Aggregate the payment.
s_mapAddressToClaimAmount[s_mapGameIdToGameResults[_gameId][i].bandAddr].add(_perBandPayment);
}
}
}