Created
February 19, 2018 21:06
-
-
Save sogoiii/1cd241fca6c4572c66a7ee646240a07f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
contract DB { | |
uint public data; | |
function updateData(uint _val) public { | |
data = _val; | |
} | |
} | |
contract Worker1 { | |
address public db; | |
function setN(uint _n) public { | |
db.delegatecall(bytes4(keccak256("updateData(uint256)")), _n); | |
} | |
function setDB(address _addr) public { | |
db = _addr; | |
} | |
} | |
contract Worker2 { | |
address public db; | |
function setN2(uint _n) public { | |
db.delegatecall(bytes4(keccak256("updateData(uint256)")), _n); | |
} | |
function setDB(address _addr) public { | |
db = _addr; | |
} | |
} | |
contract Factory { | |
address worker; | |
function updateWorker(address _w) public { | |
worker = _w; | |
} | |
function getWorker() view public returns (address) { | |
return worker; | |
} | |
function doWork(uint _val, string fnName) public { | |
worker.call(bytes4(keccak256(fnName)), _val); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment