@@ -130,6 +130,12 @@ public final class Crypto { | |||||
return new CryptoProviderInfo(pd.getFullName(), algorithms); | return new CryptoProviderInfo(pd.getFullName(), algorithms); | ||||
} | } | ||||
/** | |||||
* 返回指定名称的密码服务提供者;如果不存在,则返回 null ; | |||||
* | |||||
* @param providerFullName | |||||
* @return | |||||
*/ | |||||
public static CryptoProvider getProvider(String providerFullName) { | public static CryptoProvider getProvider(String providerFullName) { | ||||
Provider<CryptoService> pd = pm.getProvider(CryptoService.class, providerFullName); | Provider<CryptoService> pd = pm.getProvider(CryptoService.class, providerFullName); | ||||
if (pd == null) { | if (pd == null) { | ||||
@@ -13,17 +13,17 @@ public class CryptoConfig implements CryptoSetting { | |||||
private short hashAlgorithm; | private short hashAlgorithm; | ||||
private boolean autoVerifyHash; | private boolean autoVerifyHash; | ||||
HashMap<String, CryptoProvider> providers; | HashMap<String, CryptoProvider> providers; | ||||
HashMap<String, CryptoAlgorithm> nameAlgorithms; | HashMap<String, CryptoAlgorithm> nameAlgorithms; | ||||
HashMap<Short, CryptoAlgorithm> codeAlgorithms; | HashMap<Short, CryptoAlgorithm> codeAlgorithms; | ||||
public CryptoConfig() { | public CryptoConfig() { | ||||
} | } | ||||
public CryptoConfig(CryptoSetting setting) { | public CryptoConfig(CryptoSetting setting) { | ||||
this.hashAlgorithm = setting.getHashAlgorithm(); | |||||
setSupportedProviders(setting.getSupportedProviders()); | |||||
setHashAlgorithm(setting.getHashAlgorithm()); | |||||
this.autoVerifyHash = setting.getAutoVerifyHash(); | this.autoVerifyHash = setting.getAutoVerifyHash(); | ||||
} | } | ||||
@@ -68,10 +68,10 @@ public class CryptoConfig implements CryptoSetting { | |||||
providers.put(cryptoProvider.getName(), cryptoProvider); | providers.put(cryptoProvider.getName(), cryptoProvider); | ||||
} | } | ||||
} | } | ||||
this.providers = providers; | |||||
this.providers = providers; | |||||
this.nameAlgorithms = nameAlgorithms; | this.nameAlgorithms = nameAlgorithms; | ||||
this.codeAlgorithms = codeAlgorithms; | this.codeAlgorithms = codeAlgorithms; | ||||
this.cryptoProviders = supportedProviders; | this.cryptoProviders = supportedProviders; | ||||
} | } | ||||
@@ -81,7 +81,7 @@ public class CryptoConfig implements CryptoSetting { | |||||
public void setHashAlgorithm(short hashAlgorithm) { | public void setHashAlgorithm(short hashAlgorithm) { | ||||
if (codeAlgorithms == null || !codeAlgorithms.containsKey(hashAlgorithm)) { | if (codeAlgorithms == null || !codeAlgorithms.containsKey(hashAlgorithm)) { | ||||
throw new LedgerException("The specified algorithm has no provider!"); | |||||
throw new LedgerException("The specified algorithm[" + hashAlgorithm + "] has no provider!"); | |||||
} | } | ||||
this.hashAlgorithm = hashAlgorithm; | this.hashAlgorithm = hashAlgorithm; | ||||
} | } | ||||
@@ -3,10 +3,15 @@ package com.jd.blockchain.ledger.core.impl; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
import com.jd.blockchain.crypto.Crypto; | |||||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||||
import com.jd.blockchain.crypto.CryptoProvider; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.ledger.CryptoSetting; | |||||
import com.jd.blockchain.ledger.LedgerInitSetting; | import com.jd.blockchain.ledger.LedgerInitSetting; | ||||
import com.jd.blockchain.ledger.core.LedgerConsts; | import com.jd.blockchain.ledger.core.LedgerConsts; | ||||
import com.jd.blockchain.ledger.core.LedgerEditor; | import com.jd.blockchain.ledger.core.LedgerEditor; | ||||
import com.jd.blockchain.ledger.core.LedgerException; | |||||
import com.jd.blockchain.ledger.core.LedgerManage; | import com.jd.blockchain.ledger.core.LedgerManage; | ||||
import com.jd.blockchain.ledger.core.LedgerRepository; | import com.jd.blockchain.ledger.core.LedgerRepository; | ||||
import com.jd.blockchain.storage.service.ExPolicyKVStorage; | import com.jd.blockchain.storage.service.ExPolicyKVStorage; | ||||
@@ -57,26 +62,83 @@ public class LedgerManager implements LedgerManage { | |||||
@Override | @Override | ||||
public LedgerRepository register(HashDigest ledgerHash, KVStorageService storageService) { | public LedgerRepository register(HashDigest ledgerHash, KVStorageService storageService) { | ||||
// 加载账本数据库; | |||||
VersioningKVStorage ledgerVersioningStorage = storageService.getVersioningKVStorage(); | VersioningKVStorage ledgerVersioningStorage = storageService.getVersioningKVStorage(); | ||||
ExPolicyKVStorage ledgerExPolicyStorage = storageService.getExPolicyKVStorage(); | ExPolicyKVStorage ledgerExPolicyStorage = storageService.getExPolicyKVStorage(); | ||||
LedgerRepository ledgerRepo = new LedgerRepositoryImpl(ledgerHash, LEDGER_PREFIX, ledgerExPolicyStorage, | LedgerRepository ledgerRepo = new LedgerRepositoryImpl(ledgerHash, LEDGER_PREFIX, ledgerExPolicyStorage, | ||||
ledgerVersioningStorage); | ledgerVersioningStorage); | ||||
LedgerRepositoryContext ledgerCtx = new LedgerRepositoryContext(); | |||||
ledgerCtx.ledgerRepo = ledgerRepo; | |||||
ledgerCtx.storageService = storageService; | |||||
// 校验 crypto service provider ; | |||||
CryptoSetting cryptoSetting = ledgerRepo.getAdminAccount().getSetting().getCryptoSetting(); | |||||
checkCryptoSetting(cryptoSetting, ledgerHash); | |||||
// 创建账本上下文; | |||||
LedgerRepositoryContext ledgerCtx = new LedgerRepositoryContext(ledgerRepo, storageService); | |||||
ledgers.put(ledgerHash, ledgerCtx); | ledgers.put(ledgerHash, ledgerCtx); | ||||
return ledgerRepo; | return ledgerRepo; | ||||
} | } | ||||
/** | |||||
* 检查账本的密码参数设置与本地节点的运行时环境是否匹配; | |||||
* | |||||
* @param cryptoSetting | |||||
* @param ledgerHash | |||||
*/ | |||||
private void checkCryptoSetting(CryptoSetting cryptoSetting, HashDigest ledgerHash) { | |||||
CryptoProvider[] cryptoProviders = cryptoSetting.getSupportedProviders(); | |||||
if (cryptoProviders == null || cryptoProviders.length == 0) { | |||||
throw new LedgerException("No supported crypto service providers has been setted in the ledger[" | |||||
+ ledgerHash.toBase58() + "]!"); | |||||
} | |||||
for (CryptoProvider cp : cryptoProviders) { | |||||
CryptoProvider regCp = Crypto.getProvider(cp.getName()); | |||||
checkCryptoProviderConsistency(regCp, cp); | |||||
} | |||||
} | |||||
/** | |||||
* 检查密码服务提供者的信息是否匹配; | |||||
* | |||||
* @param registeredProvider | |||||
* @param settingProvider | |||||
*/ | |||||
private void checkCryptoProviderConsistency(CryptoProvider registeredProvider, CryptoProvider settingProvider) { | |||||
if (registeredProvider == null) { | |||||
throw new LedgerException("Crypto service provider[" + settingProvider.getName() | |||||
+ "] has not registered in the runtime environment of current peer!"); | |||||
} | |||||
CryptoAlgorithm[] runtimeAlgothms = registeredProvider.getAlgorithms(); | |||||
CryptoAlgorithm[] settingAlgothms = settingProvider.getAlgorithms(); | |||||
if (runtimeAlgothms.length != settingAlgothms.length) { | |||||
throw new LedgerException("Crypto service provider[" + settingProvider.getName() | |||||
+ "] has not registered in runtime of current peer!"); | |||||
} | |||||
HashMap<Short, CryptoAlgorithm> runtimeAlgothmMap = new HashMap<Short, CryptoAlgorithm>(); | |||||
for (CryptoAlgorithm alg : runtimeAlgothms) { | |||||
runtimeAlgothmMap.put(alg.code(), alg); | |||||
} | |||||
for (CryptoAlgorithm alg : settingAlgothms) { | |||||
CryptoAlgorithm regAlg = runtimeAlgothmMap.get(alg.code()); | |||||
if (regAlg == null) { | |||||
throw new LedgerException( | |||||
String.format("Crypto algorithm[%s] is not defined by provider[%s] in runtime of current peer!", | |||||
alg.toString(), registeredProvider.getName())); | |||||
} | |||||
if (!regAlg.name().equals(alg.name())) { | |||||
throw new LedgerException(String.format( | |||||
"Crypto algorithm[%s] do not match the same code algorithm[%s] defined by provider[%s] in runtime of current peer!", | |||||
CryptoAlgorithm.getString(alg), CryptoAlgorithm.getString(regAlg), | |||||
registeredProvider.getName())); | |||||
} | |||||
} | |||||
} | |||||
@Override | @Override | ||||
public void unregister(HashDigest ledgerHash) { | public void unregister(HashDigest ledgerHash) { | ||||
LedgerRepositoryContext ledgerCtx = ledgers.get(ledgerHash); | |||||
LedgerRepositoryContext ledgerCtx = ledgers.remove(ledgerHash); | |||||
if (ledgerCtx != null) { | if (ledgerCtx != null) { | ||||
ledgerCtx.ledgerRepo.close(); | ledgerCtx.ledgerRepo.close(); | ||||
ledgers.remove(ledgerHash); | |||||
ledgerCtx.ledgerRepo = null; | |||||
ledgerCtx.storageService = null; | |||||
} | } | ||||
} | } | ||||
@@ -88,18 +150,6 @@ public class LedgerManager implements LedgerManage { | |||||
*/ | */ | ||||
@Override | @Override | ||||
public LedgerEditor newLedger(LedgerInitSetting initSetting, KVStorageService storageService) { | public LedgerEditor newLedger(LedgerInitSetting initSetting, KVStorageService storageService) { | ||||
// GenesisLedgerStorageProxy genesisStorageProxy = new | |||||
// GenesisLedgerStorageProxy(); | |||||
// BufferedKVStorage bufferedStorage = new | |||||
// BufferedKVStorage(genesisStorageProxy, genesisStorageProxy, false); | |||||
// LedgerEditor genesisBlockEditor = | |||||
// LedgerTransactionalEditor.createEditor(initSetting, | |||||
// bufferedStorage, bufferedStorage); | |||||
// return new LedgerInitializer(genesisBlockEditor, bufferedStorage, | |||||
// genesisStorageProxy, storageService, this); | |||||
LedgerEditor genesisBlockEditor = LedgerTransactionalEditor.createEditor(initSetting, LEDGER_PREFIX, | LedgerEditor genesisBlockEditor = LedgerTransactionalEditor.createEditor(initSetting, LEDGER_PREFIX, | ||||
storageService.getExPolicyKVStorage(), storageService.getVersioningKVStorage()); | storageService.getExPolicyKVStorage(), storageService.getVersioningKVStorage()); | ||||
return genesisBlockEditor; | return genesisBlockEditor; | ||||
@@ -110,10 +160,16 @@ public class LedgerManager implements LedgerManage { | |||||
return LEDGER_PREFIX + base58LedgerHash + LedgerConsts.KEY_SEPERATOR; | return LEDGER_PREFIX + base58LedgerHash + LedgerConsts.KEY_SEPERATOR; | ||||
} | } | ||||
private static class LedgerRepositoryContext { | private static class LedgerRepositoryContext { | ||||
private LedgerRepository ledgerRepo; | |||||
public final LedgerRepository ledgerRepo; | |||||
private KVStorageService storageService; | |||||
public final KVStorageService storageService; | |||||
public LedgerRepositoryContext(LedgerRepository ledgerRepo, KVStorageService storageService) { | |||||
this.ledgerRepo = ledgerRepo; | |||||
this.storageService = storageService; | |||||
} | |||||
} | } | ||||
} | } |
@@ -57,6 +57,7 @@ public class LedgerManagerTest { | |||||
DataContractRegistry.register(UserRegisterOperation.class); | DataContractRegistry.register(UserRegisterOperation.class); | ||||
DataContractRegistry.register(DataAccountRegisterOperation.class); | DataContractRegistry.register(DataAccountRegisterOperation.class); | ||||
DataContractRegistry.register(BlockBody.class); | DataContractRegistry.register(BlockBody.class); | ||||
DataContractRegistry.register(CryptoProvider.class); | |||||
} | } | ||||
@@ -20,6 +20,7 @@ public interface CryptoSetting { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
@DataField(order = 0, refContract = true, list = true) | |||||
public CryptoProvider[] getSupportedProviders(); | public CryptoProvider[] getSupportedProviders(); | ||||
@@ -4,8 +4,6 @@ import com.jd.blockchain.consensus.service.NodeServer; | |||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.tools.initializer.LedgerBindingConfig; | import com.jd.blockchain.tools.initializer.LedgerBindingConfig; | ||||
import java.util.List; | |||||
public interface LedgerBindingConfigAware { | public interface LedgerBindingConfigAware { | ||||
void setConfig(LedgerBindingConfig config); | void setConfig(LedgerBindingConfig config); | ||||
@@ -5,10 +5,6 @@ import java.util.List; | |||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
import javax.annotation.PostConstruct; | |||||
import javax.annotation.PreDestroy; | |||||
import com.jd.blockchain.ledger.*; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
@@ -35,6 +31,21 @@ import com.jd.blockchain.consensus.service.NodeServer; | |||||
import com.jd.blockchain.consensus.service.ServerSettings; | import com.jd.blockchain.consensus.service.ServerSettings; | ||||
import com.jd.blockchain.consensus.service.StateMachineReplicate; | import com.jd.blockchain.consensus.service.StateMachineReplicate; | ||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.ledger.ContractCodeDeployOperation; | |||||
import com.jd.blockchain.ledger.ContractEventSendOperation; | |||||
import com.jd.blockchain.ledger.CryptoSetting; | |||||
import com.jd.blockchain.ledger.DataAccountKVSetOperation; | |||||
import com.jd.blockchain.ledger.DataAccountRegisterOperation; | |||||
import com.jd.blockchain.ledger.EndpointRequest; | |||||
import com.jd.blockchain.ledger.LedgerBlock; | |||||
import com.jd.blockchain.ledger.LedgerInitOperation; | |||||
import com.jd.blockchain.ledger.NodeRequest; | |||||
import com.jd.blockchain.ledger.Operation; | |||||
import com.jd.blockchain.ledger.TransactionContent; | |||||
import com.jd.blockchain.ledger.TransactionContentBody; | |||||
import com.jd.blockchain.ledger.TransactionRequest; | |||||
import com.jd.blockchain.ledger.TransactionResponse; | |||||
import com.jd.blockchain.ledger.UserRegisterOperation; | |||||
import com.jd.blockchain.ledger.core.LedgerAdminAccount; | import com.jd.blockchain.ledger.core.LedgerAdminAccount; | ||||
import com.jd.blockchain.ledger.core.LedgerManage; | import com.jd.blockchain.ledger.core.LedgerManage; | ||||
import com.jd.blockchain.ledger.core.LedgerRepository; | import com.jd.blockchain.ledger.core.LedgerRepository; | ||||
@@ -68,35 +79,17 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag | |||||
public static final int MIN_GATEWAY_ID = 10000; | public static final int MIN_GATEWAY_ID = 10000; | ||||
// @Autowired | |||||
// private PeerSettings peerSetting; | |||||
// @Autowired | |||||
// private ConsensusTransactionService consensusService; | |||||
// private ConsensusPeer consensusReplica; | |||||
@Autowired | @Autowired | ||||
private LedgerManage ledgerManager; | private LedgerManage ledgerManager; | ||||
@Autowired | @Autowired | ||||
private DbConnectionFactory connFactory; | private DbConnectionFactory connFactory; | ||||
// private Map<HashDigest, DbConnection> ledgerConns = new | |||||
// ConcurrentHashMap<>(); | |||||
private Map<HashDigest, MsgQueueMessageDispatcher> ledgerTxConverters = new ConcurrentHashMap<>(); | private Map<HashDigest, MsgQueueMessageDispatcher> ledgerTxConverters = new ConcurrentHashMap<>(); | ||||
private Map<HashDigest, NodeServer> ledgerPeers = new ConcurrentHashMap<>(); | private Map<HashDigest, NodeServer> ledgerPeers = new ConcurrentHashMap<>(); | ||||
private Map<HashDigest, CryptoSetting> ledgerCryptoSettings = new ConcurrentHashMap<>(); | private Map<HashDigest, CryptoSetting> ledgerCryptoSettings = new ConcurrentHashMap<>(); | ||||
// private Map<ConsensusNode, ConsensusRealm> nodeRealms = new | |||||
// ConcurrentHashMap<>(); | |||||
// private Map<HashDigest, ConsensusRealm> ledgerRealms = new | |||||
// ConcurrentHashMap<>(); | |||||
// private Map<HashDigest, ConsensusRealm> ledgerRealmsNoConflict = new | |||||
// ConcurrentHashMap<>(); | |||||
private LedgerBindingConfig config; | private LedgerBindingConfig config; | ||||
@@ -106,9 +99,6 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag | |||||
@Autowired | @Autowired | ||||
private StateMachineReplicate consensusStateManager; | private StateMachineReplicate consensusStateManager; | ||||
// private static int step = 0; | |||||
// private static int temp = 0; | |||||
static { | static { | ||||
DataContractRegistry.register(LedgerInitOperation.class); | DataContractRegistry.register(LedgerInitOperation.class); | ||||
DataContractRegistry.register(LedgerBlock.class); | DataContractRegistry.register(LedgerBlock.class); | ||||
@@ -134,24 +124,6 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag | |||||
} | } | ||||
@PostConstruct | |||||
private void init() { | |||||
} | |||||
@PreDestroy | |||||
private void destroy() { | |||||
// DbConnection[] conns = ledgerConns.values().toArray(new DbConnection[ledgerConns.size()]); | |||||
// ledgerConns.clear(); | |||||
// for (DbConnection conn : conns) { | |||||
// try { | |||||
// conn.close(); | |||||
// } catch (Exception e) { | |||||
// // Ignore; | |||||
// } | |||||
// } | |||||
} | |||||
/** | /** | ||||
* 接入认证; | * 接入认证; | ||||
* | * | ||||
@@ -234,42 +206,8 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag | |||||
HashDigest[] ledgerHashs = config.getLedgerHashs(); | HashDigest[] ledgerHashs = config.getLedgerHashs(); | ||||
for (HashDigest ledgerHash : ledgerHashs) { | for (HashDigest ledgerHash : ledgerHashs) { | ||||
setConfig(config,ledgerHash); | setConfig(config,ledgerHash); | ||||
// LedgerBindingConfig.BindingConfig bindingConfig = config.getLedger(ledgerHash); | |||||
// DbConnection dbConnNew = connFactory.connect(bindingConfig.getDbConnection().getUri(), | |||||
// bindingConfig.getDbConnection().getPassword()); | |||||
// LedgerRepository ledgerRepository = ledgerManager.register(ledgerHash, dbConnNew.getStorageService()); | |||||
// | |||||
// // load provider; | |||||
// LedgerAdminAccount ledgerAdminAccount = ledgerRepository.getAdminAccount(); | |||||
// String consensusProvider = ledgerAdminAccount.getSetting().getConsensusProvider(); | |||||
// ConsensusProvider provider = ConsensusProviders.getProvider(consensusProvider); | |||||
// // find current node; | |||||
// Bytes csSettingBytes = ledgerAdminAccount.getSetting().getConsensusSetting(); | |||||
// ConsensusSettings csSettings = provider.getSettingsFactory().getConsensusSettingsEncoder() | |||||
// .decode(csSettingBytes.toBytes()); | |||||
// NodeSettings currentNode = null; | |||||
// for (NodeSettings nodeSettings : csSettings.getNodes()) { | |||||
// if (nodeSettings.getAddress().equals(bindingConfig.getParticipant().getAddress())) { | |||||
// currentNode = nodeSettings; | |||||
// } | |||||
// } | |||||
// if (currentNode == null) { | |||||
// throw new IllegalArgumentException( | |||||
// "Current node is not found from the consensus settings of ledger[" + ledgerHash.toBase58() | |||||
// + "]!"); | |||||
// } | |||||
// ServerSettings serverSettings = provider.getServerFactory().buildServerSettings(ledgerHash.toBase58(), csSettings, currentNode.getAddress()); | |||||
// | |||||
// NodeServer server = provider.getServerFactory().setupServer(serverSettings, consensusMessageHandler, | |||||
// consensusStateManager); | |||||
// ledgerPeers.put(ledgerHash, server); | |||||
// ledgerCryptoSettings.put(ledgerHash, ledgerAdminAccount.getSetting().getCryptoSetting()); | |||||
} | } | ||||
// remove duplicate consensus realm,and establish consensus peer and consensus | |||||
// realm corresponding relationship | |||||
// initBindingConfig(config); | |||||
this.config = config; | this.config = config; | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
@@ -314,46 +252,6 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag | |||||
return server; | return server; | ||||
} | } | ||||
// private void initBindingConfig(LedgerBindingConfig config) { | |||||
// boolean intersection = false; | |||||
// // to remove intersection consensus realm | |||||
// for (HashDigest hashDigest : ledgerRealms.keySet()) { | |||||
// ConsensusRealm consensusRealm1i = ledgerRealms.get(hashDigest); | |||||
// for (ConsensusRealm consensusRealm1j : ledgerRealms.values()) { | |||||
// // avoid compare with myself | |||||
// if (consensusRealm1i.equals(consensusRealm1j)) { | |||||
// continue; | |||||
// } | |||||
// if (consensusRealm1i.hasIntersection(consensusRealm1j)) { | |||||
// intersection = true; | |||||
// break; | |||||
// } | |||||
// } | |||||
// // prompt consensus realm conflict info | |||||
// if (intersection == true) { | |||||
// ConsoleUtils.info("\r\nconsensus realm intersection with other consensus | |||||
// realm\r\n"); | |||||
// continue; | |||||
// } | |||||
// if (intersection == false) { | |||||
// // add consensus realm without conflict to ledgerRealmsNoConflict | |||||
// ledgerRealmsNoConflict.put(hashDigest, consensusRealm1i); | |||||
// | |||||
// // String consensusSystemFile = | |||||
// config.getLedger(hashDigest).getCsConfigFile(); | |||||
// int currentId = config.getLedger(hashDigest).getParticipant().getId(); | |||||
// // init consensusSystemConfig; | |||||
// ConsensusProperties csProps = | |||||
// ConsensusProperties.resolve(consensusRealm1i.getSetting()); | |||||
// ConsensusPeer consensusPeer = new ConsensusPeer(consensusRealm1i, currentId, | |||||
// consensusService, | |||||
// csProps.getProperties()); | |||||
// ledgerPeers.put(hashDigest, consensusPeer); | |||||
// } | |||||
// } // END OF FOR:get ledgerRealmsNoConflict and ledgerPeers | |||||
// | |||||
// } | |||||
@Override | @Override | ||||
public ConsensusRealm[] getRealms() { | public ConsensusRealm[] getRealms() { | ||||
throw new IllegalStateException("Not implemented!"); | throw new IllegalStateException("Not implemented!"); | ||||
@@ -364,45 +262,6 @@ public class ManagementController implements LedgerBindingConfigAware, PeerManag | |||||
for (NodeServer peer : ledgerPeers.values()) { | for (NodeServer peer : ledgerPeers.values()) { | ||||
runRealm(peer); | runRealm(peer); | ||||
} | } | ||||
// try { | |||||
// | |||||
// // for (ConsensusPeer peer : ledgerPeers.values()) { | |||||
// for (Map.Entry<HashDigest, ConsensusPeer> entry : ledgerPeers.entrySet()) { | |||||
// HashDigest ledgerHash = entry.getKey(); | |||||
// ConsensusPeer peer = entry.getValue(); | |||||
// // TODO: 多线程启动; | |||||
// ConsensusNode[] nodes = peer.getConsensusRealm().getNodes(); | |||||
// StringBuilder consensusInfo = new StringBuilder(); | |||||
// for (ConsensusNode node : nodes) { | |||||
// consensusInfo.append( | |||||
// String.format("[%s]-%s; ", node.getAddress(), | |||||
// node.getConsensusAddress().toString())); | |||||
// } | |||||
// LOGGER.debug(String.format("-------- start consensus peer[Id=%s] --Nodes=%s | |||||
// -------------", | |||||
// peer.getCurrentId(), consensusInfo.toString())); | |||||
// peer.start(); | |||||
// // 设置消息队列 | |||||
// MsgQueueMessageDispatcher messageDispatcher = ledgerTxConverters.get(ledgerHash); | |||||
// | |||||
// if (messageDispatcher == null) { | |||||
// LedgerBindingConfig.BindingConfig bindingConfig = | |||||
// this.config.getLedger(ledgerHash); | |||||
// MQConnectionConfig mqConnection = bindingConfig.getMqConnection(); | |||||
// if (mqConnection != null && mqConnection.getServer() != null) { | |||||
// MessageQueueConfig mqConfig = new | |||||
// MessageQueueConfig(mqConnection.getServer(), | |||||
// mqConnection.getTopic()); | |||||
// messageDispatcher = MessageDispatcherFactory.newInstance(mqConfig, peer); | |||||
// Executors.newSingleThreadExecutor().execute(messageDispatcher); // 启动监听 | |||||
// } | |||||
// } | |||||
// } | |||||
// } catch (Exception e) { | |||||
// LOGGER.error("Error occurred on starting all consensus realms! --" + | |||||
// e.getMessage(), e); | |||||
// throw new IllegalStateException(e.getMessage(), e); | |||||
// } | |||||
} | } | ||||
@Override | @Override | ||||
@@ -45,6 +45,9 @@ public class LedgerInitProperties { | |||||
// 共识服务提供者;必须; | // 共识服务提供者;必须; | ||||
public static final String CONSENSUS_SERVICE_PROVIDER = "consensus.service-provider"; | public static final String CONSENSUS_SERVICE_PROVIDER = "consensus.service-provider"; | ||||
// 密码服务提供者列表,以英文逗点“,”分隔;必须; | |||||
public static final String CRYPTO_SERVICE_PROVIDER = "crypto.service-providers"; | |||||
private byte[] ledgerSeed; | private byte[] ledgerSeed; | ||||