forked from bcosorg/bcos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCAAction.sol
94 lines (65 loc) · 2.4 KB
/
CAAction.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
pragma solidity ^0.4.4;
import "Base.sol";
import "StringTool.sol";
contract CAAction is Base,StringTool {
struct CaInfo
{
string hash; // 节点机构证书哈希
string pubkey;// 公钥
string orgname; // 机构名称
uint notbefore;
uint notafter;
CaStatus status;
string whitelist; //;分割
string blacklist;
uint blocknumber;
}
mapping(string =>CaInfo) m_cadata;
string[] m_hashs;
function CAAction(address _systemproxy) {
}
//更新证书信息
function update (string _hash,string _pubkey,string _orgname,uint _notbefore,uint _notafter,CaStatus _status,string _whitelist,string _blacklist) returns(bool) {
bool find=false;
for( uint i=0;i<m_hashs.length;i++){
if( equal(_hash , m_hashs[i]) ){
find=true;
break;
}
}
if( find == false ){
m_hashs.push(_hash);
}
m_cadata[_hash]=CaInfo(_hash,_pubkey,_orgname,_notbefore,_notafter,_status,_whitelist,_blacklist,block.number);
return true;
}
//更新证书状态
function updateStatus(string _hash,CaStatus _status) returns(bool){
bool find=false;
for( uint i=0;i<m_hashs.length;i++){
if( equal(_hash , m_hashs[i]) ){
find=true;
break;
}
}
if( find == false ){
return false;
}
m_cadata[_hash].status=_status;
return true;
}
//查询节点信息
function get(string _hash) constant returns(string,string,string,uint,uint,CaStatus,uint){
return (m_cadata[_hash].hash,m_cadata[_hash].pubkey,m_cadata[_hash].orgname,m_cadata[_hash].notbefore,m_cadata[_hash].notafter,m_cadata[_hash].status,m_cadata[_hash].blocknumber);
}
//查询节点ip列表
function getIp(string _hash) constant returns(string,string){
return (m_cadata[_hash].whitelist,m_cadata[_hash].blacklist);
}
function getHashsLength() constant returns(uint){
return m_hashs.length;
}
function getHash(uint _index) constant returns(string){
return m_hashs[_index];
}
}