Browse Source

use the outerTomConfig for gateway's auth;

tags/1.1.5
zhaoguangwei 5 years ago
parent
commit
18efe924dd
2 changed files with 18 additions and 14 deletions
  1. +12
    -10
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java
  2. +6
    -4
      source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitCommand.java

+ 12
- 10
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java View File

@@ -13,6 +13,8 @@ import com.jd.blockchain.consensus.service.*;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.transaction.TxResponseMessage;
import com.jd.blockchain.utils.ConsoleUtils;
import com.jd.blockchain.utils.StringUtils;
import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +62,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer

private TOMConfiguration tomConfig;

// private TOMConfiguration outerTomConfig;
private TOMConfiguration outerTomConfig;

private HostsConfig hostsConfig;
private Properties systemConfig;
@@ -130,26 +132,26 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
}

protected void initConfig(int id, Properties systemsConfig, HostsConfig hostConfig) {
// byte[] serialHostConf = BinarySerializeUtils.serialize(hostConfig);
// Properties sysConfClone = (Properties)systemsConfig.clone();
byte[] serialHostConf = BinarySerializeUtils.serialize(hostConfig);
Properties sysConfClone = (Properties)systemsConfig.clone();
int port = hostConfig.getPort(id);
// hostConfig.add(id, DEFAULT_BINDING_HOST, port);

//if ledger-init.sh set up the -DhostIp=xxx, then get it;
String preHostPort = System.getProperty("hostPort");
if(preHostPort != null && preHostPort.length()>0){
if(!StringUtils.isEmpty(preHostPort)){
port = NumberUtils.parseNumber(preHostPort, Integer.class);
System.out.println("###peer-startup.sh###,set up the -DhostPort="+port);
ConsoleUtils.info("###peer-startup.sh###,set up the -DhostPort="+port);
}

String preHostIp = System.getProperty("hostIp");
if(preHostIp != null && preHostIp.length()>0){
if(!StringUtils.isEmpty(preHostIp)){
hostConfig.add(id, preHostIp, port);
System.out.println("###peer-startup.sh###,set up the -DhostIp="+preHostIp);
ConsoleUtils.info("###peer-startup.sh###,set up the -DhostIp="+preHostIp);
}

this.tomConfig = new TOMConfiguration(id, systemsConfig, hostConfig);
// this.outerTomConfig = new TOMConfiguration(id, systemsConfig, hostConfig);
this.outerTomConfig = new TOMConfiguration(id, sysConfClone, BinarySerializeUtils.deserialize(serialHostConf));
}

@Override
@@ -168,7 +170,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
}

public TOMConfiguration getTomConfig() {
return tomConfig;
return outerTomConfig;
}

public int getId() {
@@ -180,7 +182,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
throw new IllegalArgumentException("ReplicaID is negative!");
}
this.tomConfig.setProcessId(id);
// this.outerTomConfig.setProcessId(id);
this.outerTomConfig.setProcessId(id);
}

public BftsmartConsensusSettings getConsensusSetting() {


+ 6
- 4
source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitCommand.java View File

@@ -2,6 +2,8 @@ package com.jd.blockchain.tools.initializer;

import java.io.File;

import com.jd.blockchain.utils.ConsoleUtils;
import com.jd.blockchain.utils.StringUtils;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -209,15 +211,15 @@ public class LedgerInitCommand {
//for dockers binding the 0.0.0.0;
//if ledger-init.sh set up the -DhostPort=xxx -DhostIp=xxx, then get it;
String preHostPort = System.getProperty("hostPort");
if(preHostPort != null && preHostPort.length()>0){
if(!StringUtils.isEmpty(preHostPort)){
int port = NumberUtils.parseNumber(preHostPort, Integer.class);
serverAddress.setPort(port);
System.out.println("###ledger-init.sh###,set up the -DhostPort="+port);
ConsoleUtils.info("###ledger-init.sh###,set up the -DhostPort="+port);
}
String preHostIp = System.getProperty("hostIp");
if(preHostIp != null && preHostIp.length()>0){
if(!StringUtils.isEmpty(preHostIp)){
serverAddress.setHost(preHostIp);
System.out.println("###ledger-init.sh###,set up the -DhostIp="+preHostIp);
ConsoleUtils.info("###ledger-init.sh###,set up the -DhostIp="+preHostIp);
}

String argServerAddress = String.format("--server.address=%s", serverAddress.getHost());


Loading…
Cancel
Save