Data Center Management Contract
Function Introduction
The data center management contract (DC management contract) provides a complete set of APIs corresponding to Data Center Management System’s node registration process.
Smart contract address: 0x9a5a8DFCCc2c7422fa5955FbC26d6506B07bfD0b
API Definition
Register Node
The Data Center Operator can submit the request information of the nodes pending registered to the DC management contract in the Default chain through this interface.
Input parameters: data center ID, node ID, data center NTT wallet, chain ID, attached args, encrypted data of the node signature;
Output parameters: none;
Function definition: enterNetByDC (string memory dcID, string memory nodeID, address dcNTTAddr, uint8 chainID, string memory nodeAddr, string memory nodeSign);
Event parameters: operator, data center ID, node ID, data center NTT wallet, chain ID, NTT Incentives (can be null), node status, attached args, encrypted data of the node signature;
Event definition: EnterNet (address indexed operator, string dcID, string nodeID, address dcNTTAddr, uint8 chainID, uint256 rewardNTT, NodeStatus status, string nodeAddr, string nodeSign);
Example:
public ReqJsonWithOfflineHashBean enterNetByDC(String sender, String dcId, String nodeId, String dcNttAddr, int chainId, String nodeAddr, String nodeSign, RequestOptions options) throws Exception {
// check sender
checkSender(sender);
// check dcID
checkNonEmpty(dcId, "dcId");
// check nodeId
checkNonEmpty(nodeId, "nodeId");
// check dcNTTAddr
checkAddress(dcNttAddr, "dc NTT address");
// check nodeAddr
checkNonEmpty(nodeAddr, "node address");
// check nodeSign
checkNonEmpty(nodeSign, "node sign");
// input params
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.add(dcId);
arrayList.add(nodeId);
arrayList.add(dcNttAddr);
arrayList.add(chainId);
arrayList.add(nodeAddr);
arrayList.add(nodeSign);
// build transaction
ReqJsonRpcBean reqJsonRpcBean = assembleTransaction(sender, NodeFunctions.ENTER_NET_BY_DC, arrayList, options, nodeContract);
String offLineHash = Hash.sha3(reqJsonRpcBean.getParams().get(0).toString());
ReqJsonWithOfflineHashBean reqJsonWithOfflineHashBean = new ReqJsonWithOfflineHashBean();
reqJsonWithOfflineHashBean.setOffLineHash(offLineHash);
reqJsonWithOfflineHashBean.setReqJsonRpcBean(reqJsonRpcBean);
return reqJsonWithOfflineHashBean;
}
Notify the Node Registration
This event allows the Data Center Operator to parse the events triggered by the node registration notification interface of the DC management contract called by the Spartan Network operators.
Event parameters: operator, data center ID, node ID, data center NTT wallet, amount of NTT Incentives, status, remarks;
Event definition: UpdateNodeStatus (address indexed operator, string dcID, string nodeID, address dcNTTAddr, uint256 rewardNTT, NodeStatus status, string remark);
Example:
public ReqJsonWithOfflineHashBean updateNodeStatus(String sender, String dcId, String nodeId,int status, BigDecimal rewardNTT,String remark, RequestOptions options) throws Exception {
// check sender
checkSender(sender);
// check dcID
checkNonEmpty(dcId, "dcId");
// check nodeId
checkNonEmpty(nodeId, "nodeId");
// check rewardNTT
checkBigIntegerEmpty(rewardNTT.toBigInteger(), "ntt reward amount");
// input params
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.add(dcId);
arrayList.add(nodeId);
arrayList.add(status);
arrayList.add(rewardNTT.toBigInteger());
arrayList.add(remark);
// build transaction
ReqJsonRpcBean reqJsonRpcBean = assembleTransaction(sender, NodeFunctions.UPDATE_NODE_STATUS, arrayList, options, nodeContract);
String offLineHash = Hash.sha3(reqJsonRpcBean.getParams().get(0).toString());
ReqJsonWithOfflineHashBean reqJsonWithOfflineHashBean = new ReqJsonWithOfflineHashBean();
reqJsonWithOfflineHashBean.setOffLineHash(offLineHash);
reqJsonWithOfflineHashBean.setReqJsonRpcBean(reqJsonRpcBean);
return reqJsonWithOfflineHashBean;
}