diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index 592e06f..125fd96 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -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) {