mirror of
https://gitee.com/BDWare/cm
synced 2025-01-10 09:54:03 +00:00
feat(cm): implement two functions in ContractManager
implement ContractManager.recoverUnitFromCheckPoint and ContractManager.getCheckPointFromUnit
This commit is contained in:
parent
ad7ba56dcf
commit
22e0127bd0
@ -1212,12 +1212,25 @@ public class ContractManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void recoverUnitFromCheckPoint(String contractId, String checkPoint) {
|
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) {
|
public String getCheckPointFromUnit(String contractId) {
|
||||||
// TODO
|
ContractClient client = getClient(contractId);
|
||||||
return null;
|
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) {
|
public String executeLocally(ContractRequest c, OnHashCallback cb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user