feat(cm): implement two functions in ContractManager

implement ContractManager.recoverUnitFromCheckPoint and ContractManager.getCheckPointFromUnit
This commit is contained in:
Frank.R.Wu 2022-03-23 18:29:24 +08:00
parent ad7ba56dcf
commit 22e0127bd0

View File

@ -1212,12 +1212,25 @@ public class ContractManager {
}
public void recoverUnitFromCheckPoint(String contractId, String checkPoint) {
// TODO
ContractClient client = getClient(contractId);
ContractRequest request = new ContractRequest();
request.setContractID(contractId);
request.setAction("setGlobal");
request.setArg(JsonUtil.parseObjectAsJsonObject(checkPoint));
request.setPublicKey(client.contractMeta.getPubkey());
request.doSignature(client.contractMeta.contract.key);
executeLocally(request, null);
}
public String getCheckPointFromUnit(String contractId) {
// TODO
return null;
ContractClient client = getClient(contractId);
ContractRequest request = new ContractRequest();
request.setContractID(contractId);
request.setAction("getGlobal");
request.setPublicKey(client.contractMeta.getPubkey());
request.doSignature(client.contractMeta.contract.key);
ContractResult result = JsonUtil.fromJson(executeLocally(request, null), ContractResult.class);
return JsonUtil.toJson(result.result);
}
public String executeLocally(ContractRequest c, OnHashCallback cb) {