Verified contractPartial
ModelCoordinator
Address0x288dcd4682d8f6b7fd849fb3dc9ba7fe57a8523e
- Balance
0.001 ETH
- Transactions
9
- Compiler
solc 0.1.6
- Same code
Only this contract
Details
- Compiler
- solc 0.1.6+commit.d41f8b7c
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 501,830
- Creation transaction
- 0x820a743eda…49e8f8b385
ModelCoordinator.sol
// Submitted by EthereumHistory (ethereumhistory.com)
contract EternalDB {
address public admin;
mapping (uint => uint[])[] data;
modifier restricted { if (msg.sender == admin) _ }
function EternalDB() {
admin = msg.sender;
data.length = 1; // 1-indexed, so things like mappings to ids will work
}
function transfer_ownership(address _admin) restricted {
admin = _admin;
}
function count() constant returns(uint) {
return data.length - 1;
}
function has(uint id) constant returns(bool) {
return id <= count();
}
function new_entry() restricted returns(uint) {
return data.length++;
}
function add(uint id, uint key, uint value) restricted {
uint[] attribute = data[id][key];
attribute[attribute.length++] = value;
}
function get_length(uint id, uint key) constant returns(uint) {
return data[id][key].length;
}
function get_entry(uint id, uint key, uint index) constant returns(uint) {
return data[id][key][index];
}
function get_all(uint id, uint key) constant returns(uint[]) {
return data[id][key];
}
function clear(uint id, uint key) restricted {
data[id][key].length = 0;
}
function delete_entry(uint id, uint key, uint index) restricted {
uint[] attribute = data[id][key];
for (uint i = index; i + 1 < attribute.length; i++) {
attribute[i] = attribute[i + 1];
}
attribute.length--;
}
}
contract AbstractModel {
function set_db(EternalDB _db);
function replace(address replacement);
}
contract ModelCoordinator {
mapping(uint => address) public models;
address public admin;
function ModelCoordinator() {
admin = msg.sender;
}
function register(uint name, AbstractModel model, EternalDB db) {
if (msg.sender == admin) {
if (models[name] != 0) {
AbstractModel old_model = AbstractModel(models[name]);
old_model.replace(model);
}
models[name] = address(model);
if (address(db) == 0) {
db = new EternalDB();
db.transfer_ownership(address(model));
}
model.set_db(db);
}
}
}
Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.