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.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DoipLocalSingleton {
|
public class DoipLocalSingleton {
|
||||||
@@ -66,36 +67,46 @@ public class DoipLocalSingleton {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
SM2KeyPair keyPair = JavaScriptEntry.getKeyPair();
|
SM2KeyPair keyPair = JavaScriptEntry.getKeyPair();
|
||||||
String repoID = "bdtest/BDRepo/" + UUID.randomUUID().toString();
|
String repoID = "";
|
||||||
String owner = ContractProcess.instance.getContract().getOwner();
|
String owner = ContractProcess.instance.getContract().getOwner();
|
||||||
String repoType = "BDO";
|
String repoType = "BDO";
|
||||||
EndpointConfig config = null;
|
EndpointConfig config = null;
|
||||||
try {
|
try {
|
||||||
if (otherConfigs != null && otherConfigs.isJsonObject()) {
|
if (otherConfigs != null && otherConfigs.isJsonObject()) {
|
||||||
config = new TempConfigStorage(otherConfigs.toString()).loadAsEndpointConfig();
|
config = new TempConfigStorage(otherConfigs.toString()).loadAsEndpointConfig();
|
||||||
|
// 获取合约启动配置
|
||||||
if (otherConfigs.getAsJsonObject().has("repoID")) {
|
if (otherConfigs.getAsJsonObject().has("repoID")) {
|
||||||
repoID = otherConfigs.getAsJsonObject().get("repoID").getAsString();
|
repoID = otherConfigs.getAsJsonObject().get("repoID").getAsString();
|
||||||
}
|
}
|
||||||
|
if (otherConfigs.getAsJsonObject().has("publicKey")) {
|
||||||
|
owner = otherConfigs.getAsJsonObject().get("publicKey").getAsString();
|
||||||
|
}
|
||||||
if (config.privateKey == null || config.publicKey == null) {
|
if (config.privateKey == null || config.publicKey == null) {
|
||||||
config.privateKey = keyPair.getPrivateKeyStr();
|
config.privateKey = keyPair.getPrivateKeyStr();
|
||||||
config.publicKey = keyPair.getPublicKeyStr();
|
config.publicKey = keyPair.getPublicKeyStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.routerURI != null && config.repoName != null) {
|
if (config.routerURI != null && config.repoName != null) {
|
||||||
AuditIrpClient irpClient = new AuditIrpClient(config);
|
try {
|
||||||
EndpointInfo endpointInfo = null;
|
AuditIrpClient irpClient = new AuditIrpClient(config);
|
||||||
for (int i = 0; i < 10; i++) {
|
EndpointInfo endpointInfo = null;
|
||||||
endpointInfo = irpClient.getEndpointInfo();
|
for (int i = 0; i < 10; i++) {
|
||||||
if (endpointInfo == null)
|
endpointInfo = irpClient.getEndpointInfo();
|
||||||
Thread.sleep(200);
|
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 参数,使用该参数作为启动端口
|
// 如果启动参数中添加了 doipStartPort 参数,使用该参数作为启动端口
|
||||||
|
|||||||
Reference in New Issue
Block a user