update contract manager

This commit is contained in:
CaiHQ 2023-03-30 23:54:50 +08:00
parent 487697aa87
commit 9cf42f1381
4 changed files with 25 additions and 21 deletions

View File

@ -29,9 +29,6 @@ sourceCompatibility = 1.8
dependencies {
api project(":common")
api 'io.prometheus:simpleclient:0.12.0'
api 'org.knowhowlab.osgi:sigar:1.6.5_01'
api 'org.bdware.doip:doip-sdk:1.1.0'
api fileTree(dir: 'libs', include: '*.jar')
api 'org.hyperic.sigar:sigar:1.6.4'
testImplementation 'junit:junit:4.13.2'
}

View File

@ -428,10 +428,6 @@ public class ContractClient {
}
public String signResult(String result) {
return contractMeta.contract.signResult(result);
}
public String getPubkey() {
return contractMeta.contract.getPublicKey();
}

View File

@ -32,8 +32,6 @@ import org.zz.gmhelper.SM2KeyPair;
import org.zz.gmhelper.SM2Util;
import java.io.*;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.*;
@ -116,6 +114,7 @@ public class ContractManager {
eventBroker = new EventBroker();
statusRecorder = new ContractStatusRecorder("./ContractManagerDB");
multiContractRecorder = new MultiContractRecorder("./ContractManagerDB");
multiContractRecorder.removeNotExist(statusRecorder);
projectRecoder = new ProjectRecorder("./ContractManagerDB");
}
@ -985,7 +984,7 @@ public class ContractManager {
}
private void setContractDOI(Contract c) {
if (DoConfig.callContractUsingDOI) {
//@TODO add Automatically register a doi instead.
ContractManifest cm = YJSPacker.getManifest(c.getScriptStr());
if (cm != null && cm.doi != null) {
if (!cm.doi.equals("")
@ -996,7 +995,6 @@ public class ContractManager {
c.setDoipFlag(true);
chainOpener.reRegister(cm.doi);
}
}
} else {
c.setDoipFlag(false);
}

View File

@ -7,6 +7,9 @@ import org.bdware.sc.db.KeyValueDBUtil;
import org.bdware.sc.db.StatusRecorder;
import org.bdware.sc.units.MultiContractMeta;
import java.util.HashSet;
import java.util.Set;
public class MultiContractRecorder extends StatusRecorder<MultiContractMeta> {
static final String dbName = CMTables.UnitContracts.toString();
static final String prefix = "Multi_C_Meta_";
@ -49,4 +52,14 @@ public class MultiContractRecorder extends StatusRecorder<MultiContractMeta> {
}
return ret;
}
public void removeNotExist(ContractStatusRecorder statusRecorder) {
Set<MultiContractMeta> toRemove = new HashSet<>();
for (String key : getStatus().keySet()) {
if (statusRecorder.getContractMeta(key) == null)
toRemove.add(getStatus().get(key));
}
for (MultiContractMeta meta : toRemove)
remove(meta);
}
}