I am passing an array of addresses into a contract from a parent contract. Using that I am generating a mapping with those address to quickly verify the msg.sender is part of the set mappings.
To check if a msg.sender
is part of the mappings I am using the restricted modifier.
contract Upload{
mapping(address => bool) managerAddresses;
string public ownerName;
string public location;
modifier restricted(){
require(managerAddresses[msg.sender]);
_;
}
constructor(address[] _managerAddressesArr,string _ownerName,string _location) public {
for(uint i = 0;i<_managerAddressesArr.length;i++){
managerAddresses[_managerAddressesArr[i]] = true;
}
ownerName = _ownerName;
}
function setLocation(string _location) restricted public{
location = _location;
}
}
But the setLocation function is unable to change the location when the restricted modifier is on and the transaction is mined but doesn't execte. Even though the address passed by the managerAddressesArr are correct and without the modifier I can execute the functions.
Also solidity gives a
Gas requirement of function Upload.setLocation(string) high: infinite
Does anyone have any idea whats wrong with the restricted modifier?