mirror of
https://gitee.com/BDWare/cm
synced 2025-01-10 09:54:03 +00:00
update contract manager
This commit is contained in:
parent
487697aa87
commit
9cf42f1381
@ -29,9 +29,6 @@ sourceCompatibility = 1.8
|
|||||||
dependencies {
|
dependencies {
|
||||||
api project(":common")
|
api project(":common")
|
||||||
api 'io.prometheus:simpleclient:0.12.0'
|
api 'io.prometheus:simpleclient:0.12.0'
|
||||||
api 'org.knowhowlab.osgi:sigar:1.6.5_01'
|
api 'org.hyperic.sigar:sigar:1.6.4'
|
||||||
api 'org.bdware.doip:doip-sdk:1.1.0'
|
|
||||||
|
|
||||||
api fileTree(dir: 'libs', include: '*.jar')
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
}
|
}
|
||||||
|
@ -428,10 +428,6 @@ public class ContractClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String signResult(String result) {
|
|
||||||
return contractMeta.contract.signResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPubkey() {
|
public String getPubkey() {
|
||||||
return contractMeta.contract.getPublicKey();
|
return contractMeta.contract.getPublicKey();
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,6 @@ import org.zz.gmhelper.SM2KeyPair;
|
|||||||
import org.zz.gmhelper.SM2Util;
|
import org.zz.gmhelper.SM2Util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Parameter;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
@ -116,6 +114,7 @@ public class ContractManager {
|
|||||||
eventBroker = new EventBroker();
|
eventBroker = new EventBroker();
|
||||||
statusRecorder = new ContractStatusRecorder("./ContractManagerDB");
|
statusRecorder = new ContractStatusRecorder("./ContractManagerDB");
|
||||||
multiContractRecorder = new MultiContractRecorder("./ContractManagerDB");
|
multiContractRecorder = new MultiContractRecorder("./ContractManagerDB");
|
||||||
|
multiContractRecorder.removeNotExist(statusRecorder);
|
||||||
projectRecoder = new ProjectRecorder("./ContractManagerDB");
|
projectRecoder = new ProjectRecorder("./ContractManagerDB");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,17 +984,16 @@ public class ContractManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setContractDOI(Contract c) {
|
private void setContractDOI(Contract c) {
|
||||||
if (DoConfig.callContractUsingDOI) {
|
//@TODO add Automatically register a doi instead.
|
||||||
ContractManifest cm = YJSPacker.getManifest(c.getScriptStr());
|
ContractManifest cm = YJSPacker.getManifest(c.getScriptStr());
|
||||||
if (cm != null && cm.doi != null) {
|
if (cm != null && cm.doi != null) {
|
||||||
if (!cm.doi.equals("")
|
if (!cm.doi.equals("")
|
||||||
&& !cm.doi.equals("null")
|
&& !cm.doi.equals("null")
|
||||||
&& c.getType() == ContractExecType.Sole && chainOpener != null) {
|
&& c.getType() == ContractExecType.Sole && chainOpener != null) {
|
||||||
c.setDOI(cm.doi);
|
c.setDOI(cm.doi);
|
||||||
c.setBuildTime(cm.buildTime);
|
c.setBuildTime(cm.buildTime);
|
||||||
c.setDoipFlag(true);
|
c.setDoipFlag(true);
|
||||||
chainOpener.reRegister(cm.doi);
|
chainOpener.reRegister(cm.doi);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.setDoipFlag(false);
|
c.setDoipFlag(false);
|
||||||
|
@ -7,6 +7,9 @@ import org.bdware.sc.db.KeyValueDBUtil;
|
|||||||
import org.bdware.sc.db.StatusRecorder;
|
import org.bdware.sc.db.StatusRecorder;
|
||||||
import org.bdware.sc.units.MultiContractMeta;
|
import org.bdware.sc.units.MultiContractMeta;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MultiContractRecorder extends StatusRecorder<MultiContractMeta> {
|
public class MultiContractRecorder extends StatusRecorder<MultiContractMeta> {
|
||||||
static final String dbName = CMTables.UnitContracts.toString();
|
static final String dbName = CMTables.UnitContracts.toString();
|
||||||
static final String prefix = "Multi_C_Meta_";
|
static final String prefix = "Multi_C_Meta_";
|
||||||
@ -49,4 +52,14 @@ public class MultiContractRecorder extends StatusRecorder<MultiContractMeta> {
|
|||||||
}
|
}
|
||||||
return ret;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user