Merge of 27-ens-usernames with develop

This commit is contained in:
Richard Ramos 2018-03-15 14:35:55 -04:00
commit 0b59eaf815
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,57 @@
pragma solidity ^0.4.17;
import "../common/Controlled.sol";
contract Factory is Controlled {
event NewKernel(address newKernel, bytes infohash);
struct Version {
uint256 blockNumber;
uint256 timestamp;
address kernel;
bytes infohash;
}
mapping (address => uint256) versionMap;
Version[] versionLog;
uint256 latestUpdate;
address latestKernel;
function Factory(address _kernel, bytes _infohash)
public
{
_setKernel(_kernel, _infohash);
}
function setKernel(address _kernel, bytes _infohash)
external
onlyController
{
_setKernel(_kernel, _infohash);
}
function getVersion(uint256 index) public view
returns(uint256 blockNumber,
uint256 timestamp,
address kernel,
bytes infohash)
{
return (versionLog[index].blockNumber,
versionLog[index].timestamp,
versionLog[index].kernel,
versionLog[index].infohash);
}
function _setKernel(address _kernel, bytes _infohash)
internal
{
require(_kernel != latestKernel);
versionMap[_kernel] = versionLog.length;
versionLog.push(Version({blockNumber: block.number, timestamp: block.timestamp, kernel: _kernel, infohash: _infohash}));
latestUpdate = block.timestamp;
latestKernel = _kernel;
NewKernel(_kernel, _infohash);
}
}

View File

@ -10,6 +10,8 @@ import "./Instance.sol";
*/
contract UpdatableInstance is Instance {
event InstanceUpdated(address oldKernel, address newKernel);
function UpdatableInstance(address _kernel)
Instance(_kernel)
public
@ -19,6 +21,7 @@ contract UpdatableInstance is Instance {
function updateUpdatableInstance(address _kernel) external {
require(msg.sender == address(this));
InstanceUpdated(kernel, _kernel);
kernel = _kernel;
}