In this little sample I try to play with modifiers, master1 creates the contrat and pass the master2 address as a parameter in the constructor.
contract testOnlyBy {
address master1;
address master2;
modifier onlyByMaster1 { if (msg.sender != master1) throw; _ }
modifier onlyByMaster2 { if (msg.sender != master2) throw; _ }
modifier onlyByMaster1or2 { if (msg.sender != master1 || msg.sender != master2) throw; _ }
// "0x6eec66e0133feb5e432584515880afad4be047f0"
function testOnlyBy(address _master2) {
master1 = msg.sender;
master2 = _master2;
}
function get() external constant returns(address ret1, address ret2) {
if (msg.sender == master1 || msg.sender == master2){
return (master1, master2);
}
}
function getonlyByMaster1() onlyByMaster1 external constant returns(address ret1, address ret2) {
return (master1, master2);
}
function getonlyByMaster2() onlyByMaster2 external constant returns(address ret1, address ret2) {
return (master1, master2);
}
function getonlyByMaster1or2() onlyByMaster1or2 external constant returns(address ret1, address ret2) {
return (master1, master2);
}
}
the get
function works as intended, but the idea is to use modifiers instead.
I don't get why getonlyByMaster1or2
returns 0x0, I though the two functions would be equivalent.
Am I missing something ?