提交 4edfe964 编写于 作者: S shaozhuguang

1、Fixed get consensus file error !

上级 f73a2280
......@@ -68,7 +68,7 @@ public class JavaContractCode extends AbstractContractCode {
@Override
public BytesValue processEvent(ContractEventContext eventContext) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Start processing event[%s] of contract[%s]...", eventContext.getEvent(), address.toString());
LOGGER.debug("Start processing event{} of contract{}...", eventContext.getEvent(), address.toString());
}
try {
return codeModule.call(new ContractExecution(eventContext));
......@@ -78,7 +78,7 @@ public class JavaContractCode extends AbstractContractCode {
throw ex;
} finally {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("End processing event[%s] of contract[%s]. ", eventContext.getEvent(), address.toString());
LOGGER.debug("End processing event{} of contract{}. ", eventContext.getEvent(), address.toString());
}
}
}
......
#网关的HTTP服务地址;
#网关的HTTP服务地址,建议直接使用0.0.0.0
http.host=0.0.0.0
#网关的HTTP服务端口;
http.port=8081
......@@ -18,6 +18,7 @@ peer.providers=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider
#数据检索服务对应URL,格式:http://{ip}:{port},例如:http://127.0.0.1:10001
#若该值不配置或配置不正确,则浏览器模糊查询部分无法正常显示
#数据检索服务模块(Argus)需单独部署,若不部署其他功能仍可正常使用
data.retrieval.url=http://127.0.0.1:10001
#默认公钥的内容(Base58编码数据);
......
......@@ -10,7 +10,7 @@ created-time=2019-08-01 14:26:58.069+0800
#共识服务提供者;必须;
consensus.service-provider=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider
#共识服务的参数配置;必须;
#共识服务的参数配置;推荐使用绝对路径;必须;
consensus.conf=classpath:bftsmart.config
#密码服务提供者列表,以英文逗点“,”分隔;必须;
......
......@@ -141,7 +141,8 @@ public class LedgerInitProperties {
public static LedgerInitProperties resolve(String initSettingFile) {
Properties props = FileUtils.readProperties(initSettingFile, "UTF-8");
return resolve(props);
File realFile = new File(initSettingFile);
return resolve(realFile.getParentFile().getPath(), props);
}
public static LedgerInitProperties resolve(InputStream in) {
......@@ -150,6 +151,10 @@ public class LedgerInitProperties {
}
public static LedgerInitProperties resolve(Properties props) {
return resolve(null, props);
}
public static LedgerInitProperties resolve(String dir, Properties props) {
String hexLedgerSeed = PropertiesUtils.getRequiredProperty(props, LEDGER_SEED).replace("-", "");
byte[] ledgerSeed = HexUtils.decode(hexLedgerSeed);
LedgerInitProperties initProps = new LedgerInitProperties(ledgerSeed);
......@@ -166,7 +171,7 @@ public class LedgerInitProperties {
initProps.consensusProvider = PropertiesUtils.getRequiredProperty(props, CONSENSUS_SERVICE_PROVIDER);
String consensusConfigFilePath = PropertiesUtils.getRequiredProperty(props, CONSENSUS_CONFIG);
try {
File consensusConfigFile = ResourceUtils.getFile(consensusConfigFilePath);
File consensusConfigFile = FileUtils.getFile(dir, consensusConfigFilePath);
initProps.consensusConfig = FileUtils.readProperties(consensusConfigFile);
} catch (FileNotFoundException e) {
throw new IllegalArgumentException(
......
......@@ -16,6 +16,7 @@ import java.io.Reader;
import java.util.ArrayList;
import java.util.Properties;
import com.jd.blockchain.utils.PathUtils;
import org.springframework.util.ResourceUtils;
/**
......@@ -482,4 +483,26 @@ public class FileUtils {
}
return path.delete();
}
/**
* 获取指定路径和位置的文件信息
*
* @param dir
* 指定路径,不要以"/"结尾
* @param resourceLocation
* 文件位置信息,可支持绝对路径、相对路径(相对dir)、classpath:前缀
* @return
*
* @throws FileNotFoundException
*/
public static File getFile(String dir, String resourceLocation) throws FileNotFoundException {
if (resourceLocation.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
return ResourceUtils.getFile(resourceLocation);
}
if (resourceLocation.startsWith(PathUtils.PATH_SEPERATOR)) {
return new File(resourceLocation);
}
String totalPath = PathUtils.concatPaths(dir, resourceLocation);
return new File(totalPath);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册