forked from synechron-finlabs/quorum-maker-nodemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkManagerContract.sol
72 lines (58 loc) · 1.91 KB
/
NetworkManagerContract.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
pragma solidity ^0.4.23;
contract NetworkManagerContract {
uint nodeCounter;
struct NodeDetails {
string nodeName;
string role;
string publickey;
string enode;
string ip;
string id;
}
mapping (string => NodeDetails)nodes;
string[] enodeList;
event print(string nodeName, string role,string publickey, string enode, string ip, string id);
function registerNode(string n, string r, string p,string e, string ip, string id) public {
nodes[e].publickey = p;
nodes[e].nodeName = n;
nodes[e].role = r;
nodes[e].ip = ip;
nodes[e].id = id;
enodeList.push(e);
emit print(n, r, p, e, ip, id);
}
function getNodeDetails(uint16 _index) constant public returns (string n, string r,string p,string ip,string e,string id,uint i) {
NodeDetails memory nodeInfo = nodes[enodeList[_index]];
return (
nodeInfo.nodeName,
nodeInfo.role,
nodeInfo.publickey,
nodeInfo.ip,
enodeList[_index],
nodeInfo.id,
_index
);
}
function getNodesCounter() public constant returns (uint) {
return enodeList.length;
}
function updateNode(string n, string r, string p, string e, string ip, string id) public {
nodes[e].publickey = p;
nodes[e].nodeName = n;
nodes[e].role = r;
nodes[e].ip = ip;
nodes[e].id = id;
emit print(n, r, p, e, ip, id);
}
function getNodeList(uint16 i) public constant returns (string n, string r,string p,string ip,string e, string id) {
NodeDetails memory nodeInfo = nodes[enodeList[i]];
return (
nodeInfo.nodeName,
nodeInfo.role,
nodeInfo.publickey,
nodeInfo.ip,
enodeList[i],
nodeInfo.id
);
}
}