mirror of
https://gitee.com/BDWare/cp.git
synced 2026-01-28 17:19:26 +00:00
feat: change start config
This commit is contained in:
@@ -20,6 +20,7 @@ import org.zz.gmhelper.SM2KeyPair;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DoipLocalSingleton {
|
||||
@@ -66,36 +67,46 @@ public class DoipLocalSingleton {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SM2KeyPair keyPair = JavaScriptEntry.getKeyPair();
|
||||
String repoID = "bdtest/BDRepo/" + UUID.randomUUID().toString();
|
||||
String repoID = "";
|
||||
String owner = ContractProcess.instance.getContract().getOwner();
|
||||
String repoType = "BDO";
|
||||
EndpointConfig config = null;
|
||||
try {
|
||||
if (otherConfigs != null && otherConfigs.isJsonObject()) {
|
||||
config = new TempConfigStorage(otherConfigs.toString()).loadAsEndpointConfig();
|
||||
// 获取合约启动配置
|
||||
if (otherConfigs.getAsJsonObject().has("repoID")) {
|
||||
repoID = otherConfigs.getAsJsonObject().get("repoID").getAsString();
|
||||
}
|
||||
if (otherConfigs.getAsJsonObject().has("publicKey")) {
|
||||
owner = otherConfigs.getAsJsonObject().get("publicKey").getAsString();
|
||||
}
|
||||
if (config.privateKey == null || config.publicKey == null) {
|
||||
config.privateKey = keyPair.getPrivateKeyStr();
|
||||
config.publicKey = keyPair.getPublicKeyStr();
|
||||
}
|
||||
|
||||
if (config.routerURI != null && config.repoName != null) {
|
||||
AuditIrpClient irpClient = new AuditIrpClient(config);
|
||||
EndpointInfo endpointInfo = null;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
endpointInfo = irpClient.getEndpointInfo();
|
||||
if (endpointInfo == null)
|
||||
Thread.sleep(200);
|
||||
try {
|
||||
AuditIrpClient irpClient = new AuditIrpClient(config);
|
||||
EndpointInfo endpointInfo = null;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
endpointInfo = irpClient.getEndpointInfo();
|
||||
if (endpointInfo == null)
|
||||
Thread.sleep(200);
|
||||
}
|
||||
// 已合约自己的配置为主
|
||||
if (endpointInfo != null) {
|
||||
repoID = Objects.equals(repoID, "") ? endpointInfo.getDoId() : repoID;
|
||||
owner = owner.equals(config.publicKey) ? owner : endpointInfo.getPubKey();
|
||||
infos.clear();
|
||||
}
|
||||
infos.add(new DoipListenerConfig(endpointInfo.getURI(), "2.1"));
|
||||
port = new URI(endpointInfo.getURI()).getPort();
|
||||
SharableVarManager.initSharableVarManager(repoID, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (endpointInfo != null) {
|
||||
repoID = endpointInfo.getDoId();
|
||||
owner = endpointInfo.getPubKey();
|
||||
infos.clear();
|
||||
}
|
||||
infos.add(new DoipListenerConfig(endpointInfo.getURI(), "2.1"));
|
||||
port = new URI(endpointInfo.getURI()).getPort();
|
||||
SharableVarManager.initSharableVarManager(repoID, config);
|
||||
}
|
||||
}
|
||||
// 如果启动参数中添加了 doipStartPort 参数,使用该参数作为启动端口
|
||||
|
||||
Reference in New Issue
Block a user