forked from icon-project/devportal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIBMCManagement.sol
311 lines (274 loc) · 9.74 KB
/
IBMCManagement.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.5.0 <0.8.0;
pragma experimental ABIEncoderV2;
import "../libraries/TypesLib.sol";
interface IBMCManagement {
/**
@notice Update BMC periphery.
@dev Caller must be an Onwer of BTP network
@param _addr Address of a new periphery.
*/
function setBMCPeriphery(address _addr) external;
/**
@notice Adding another Onwer.
@dev Caller must be an Onwer of BTP network
@param _owner Address of a new Onwer.
*/
function addOwner(address _owner) external;
/**
@notice Removing an existing Owner.
@dev Caller must be an Owner of BTP network
@dev If only one Owner left, unable to remove the last Owner
@param _owner Address of an Owner to be removed.
*/
function removeOwner(address _owner) external;
/**
@notice Checking whether one specific address has Owner role.
@dev Caller can be ANY
@param _owner Address needs to verify.
*/
function isOwner(address _owner) external view returns (bool);
/**
@notice Registers the smart contract for the service.
@dev Caller must be an operator of BTP network.
@param _svc Name of the service
*/
function approveService(string calldata _svc, bool isAccepted) external;
/**
@notice De-registers the smart contract for the service.
@dev Caller must be an operator of BTP network.
@param _svc Name of the service
*/
function removeService(string calldata _svc) external;
/**
@notice Registers BMV for the network.
@dev Caller must be an operator of BTP network.
@param _net Network Address of the blockchain
@param _addr Address of BMV
*/
function addVerifier(string calldata _net, address _addr) external;
/**
@notice De-registers BMV for the network.
@dev Caller must be an operator of BTP network.
@param _net Network Address of the blockchain
*/
function removeVerifier(string calldata _net) external;
/**
@notice Initializes status information for the link.
@dev Caller must be an operator of BTP network.
@param _link BTP Address of connected BMC
*/
function addLink(string calldata _link) external;
/**
@notice Set the link and status information.
@dev Caller must be an operator of BTP network.
@param _link BTP Address of connected BMC
@param _blockInterval Block interval of a connected link
@param _maxAggregation Set max aggreation of a connected link
@param _delayLimit Set delay limit of a connected link
*/
function setLink(
string calldata _link,
uint256 _blockInterval,
uint256 _maxAggregation,
uint256 _delayLimit
) external;
/**
@notice Removes the link and status information.
@dev Caller must be an operator of BTP network.
@param _link BTP Address of connected BMC
*/
function removeLink(string calldata _link) external;
/**
@notice Add route to the BMC.
@dev Caller must be an operator of BTP network.
@param _dst BTP Address of the destination BMC
@param _link BTP Address of the next BMC for the destination
*/
function addRoute(string calldata _dst, string calldata _link) external;
/**
@notice Remove route to the BMC.
@dev Caller must be an operator of BTP network.
@param _dst BTP Address of the destination BMC
*/
function removeRoute(string calldata _dst) external;
/**
@notice Registers relay for the network.
@dev Caller must be an operator of BTP network.
@param _link BTP Address of connected BMC
@param _addrs A list of Relays
*/
function addRelay(string calldata _link, address[] memory _addrs) external;
/**
@notice Unregisters Relay for the network.
@dev Caller must be an operator of BTP network.
@param _link BTP Address of connected BMC
@param _addrs A list of Relays
*/
function removeRelay(string calldata _link, address _addrs) external;
/**
@notice Get registered services.
@return _servicers An array of Service.
*/
function getServices()
external
view
returns (Types.Service[] memory _servicers);
/**
@notice Get registered verifiers.
@return _verifiers An array of Verifier.
*/
function getVerifiers()
external
view
returns (Types.Verifier[] memory _verifiers);
/**
@notice Get registered links.
@return _links An array of links ( BTP Addresses of the BMCs ).
*/
function getLinks() external view returns (string[] memory _links);
/**
@notice Get routing information.
@return _routes An array of Route.
*/
function getRoutes() external view returns (Types.Route[] memory _routes);
/**
@notice Get registered relays.
@param _link BTP Address of the connected BMC.
@return _relayes A list of relays.
*/
function getRelays(string calldata _link)
external
view
returns (address[] memory _relayes);
/**
@notice Get BSH services by name. Only called by BMC periphery.
@param _serviceName BSH service name
@return BSH service address
*/
function getBshServiceByName(string memory _serviceName)
external
view
returns (address);
/**
@notice Get BMV services by net. Only called by BMC periphery.
@param _net net of the connected network
@return BMV service address
*/
function getBmvServiceByNet(string memory _net)
external
view
returns (address);
/**
@notice Get pending service requests. Only called by BMC periphery.
@return List of all requests.
*/
function getPendingRequest() external view returns (Types.Request[] memory);
/**
@notice Get link info. Only called by BMC periphery.
@param _to link's BTP address
@return Link info
*/
function getLink(string memory _to)
external
view
returns (Types.Link memory);
/**
@notice Get rotation sequence by link. Only called by BMC periphery.
@param _prev BTP Address of the previous BMC
@return Rotation sequence
*/
function getLinkRxSeq(string calldata _prev)
external
view
returns (uint256);
/**
@notice Get transaction sequence by link. Only called by BMC periphery.
@param _prev BTP Address of the previous BMC
@return Transaction sequence
*/
function getLinkTxSeq(string calldata _prev)
external
view
returns (uint256);
/**
@notice Get relays by link. Only called by BMC periphery.
@param _prev BTP Address of the previous BMC
@return List of relays' addresses
*/
function getLinkRelays(string calldata _prev)
external
view
returns (address[] memory);
/**
@notice Get relays status by link. Only called by BMC periphery.
@param _prev BTP Address of the previous BMC
@return Relay status of all relays
*/
function getRelayStatusByLink(string memory _prev)
external
view
returns (Types.RelayStats[] memory);
/**
@notice Update pending request. Only called by BMC periphery.
@param _req service request
*/
function updatePendingReq(Types.Request memory _req) external;
/**
@notice Update rotation sequence by link. Only called by BMC periphery.
@param _prev BTP Address of the previous BMC
@param _val increment value
*/
function updateLinkRxSeq(string calldata _prev, uint256 _val) external;
/**
@notice Increase transaction sequence by 1.
@param _prev BTP Address of the previous BMC
*/
function updateLinkTxSeq(string memory _prev) external;
/**
@notice Add a reachable BTP address to link. Only called by BMC periphery.
@param _prev BTP Address of the previous BMC
@param _to BTP Address of the reachable
*/
function updateLinkReachable(string memory _prev, string memory _to)
external;
/**
@notice Remove a reachable BTP address. Only called by BMC periphery.
@param _index reachable index to remove
*/
function deleteLinkReachable(string memory _prev, uint256 _index) external;
/**
@notice Update relay status. Only called by BMC periphery.
@param _relay relay address
@param _blockCountVal increment value for block counter
@param _msgCountVal increment value for message counter
*/
function updateRelayStats(
address _relay,
uint256 _blockCountVal,
uint256 _msgCountVal
) external;
/**
@notice resolve next BMC. Only called by BMC periphery.
@param _dstNet net of BTP network address
@return BTP address of next BMC and destinated BMC
*/
function resolveRoute(string memory _dstNet)
external
view
returns (string memory, string memory);
/**
@notice rotate relay for relay address. Only called by BMC periphery.
@param _link BTP network address of connected BMC
@param _currentHeight current block height of MTA from BMV
@param _relayMsgHeight block height of last relayed BTP Message
@param _hasMsg check if message exists
@return relay address
*/
function rotateRelay(
string memory _link,
uint256 _currentHeight,
uint256 _relayMsgHeight,
bool _hasMsg
) external returns (address);
}