Search in sources :

Example 1 with BftsmartNodeServer

use of com.jd.blockchain.consensus.bftsmart.service.BftsmartNodeServer in project jdchain-core by blockchain-jd-com.

the class ProxyClientTest method peerStart.

public void peerStart(BftsmartNodeServer[] nodeServers) {
    BftsmartNodeSettings[] nodesSettings = new BftsmartNodeSettings[nodeNum];
    for (int i = 0; i < nodeNum; i++) {
        BlockchainKeypair keyPair = BlockchainKeyGenerator.getInstance().generate();
        PubKey pubKey = keyPair.getPubKey();
        NetworkAddress peerNodeServ = new NetworkAddress("127.0.0.1", peerStartPort + i * 10);
        NodeSettings node = new BftsmartNodeConfig(pubKey, i, peerNodeServ);
        nodesSettings[i] = (BftsmartNodeSettings) node;
    }
    BftsmartConsensusConfig consensusConfig = new BftsmartConsensusConfig(nodesSettings, PropertiesUtils.getOrderedValues(bftsmartConf), 0);
    for (int j = 0; j < nodeNum; j++) {
        BftsmartServerSettingConfig serverSettings = new BftsmartServerSettingConfig();
        serverSettings.setReplicaSettings(nodesSettings[j]);
        serverSettings.setConsensusSettings(consensusConfig);
        BftsmartNodeServer server = new BftsmartNodeServer(serverSettings, null, null, new MemoryStorage("test"));
        nodeServers[j] = server;
        nodeStartPools.execute(() -> {
            server.start();
            startPeer.countDown();
        });
    }
}
Also used : PubKey(com.jd.blockchain.crypto.PubKey) NodeSettings(com.jd.blockchain.consensus.NodeSettings) BftsmartNodeSettings(com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings) BftsmartServerSettingConfig(com.jd.blockchain.consensus.bftsmart.service.BftsmartServerSettingConfig) BftsmartNodeSettings(com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings) NetworkAddress(utils.net.NetworkAddress) BftsmartConsensusConfig(com.jd.blockchain.consensus.bftsmart.BftsmartConsensusConfig) BlockchainKeypair(com.jd.blockchain.ledger.BlockchainKeypair) BftsmartNodeConfig(com.jd.blockchain.consensus.bftsmart.BftsmartNodeConfig) BftsmartNodeServer(com.jd.blockchain.consensus.bftsmart.service.BftsmartNodeServer) MemoryStorage(utils.io.MemoryStorage)

Aggregations

NodeSettings (com.jd.blockchain.consensus.NodeSettings)1 BftsmartConsensusConfig (com.jd.blockchain.consensus.bftsmart.BftsmartConsensusConfig)1 BftsmartNodeConfig (com.jd.blockchain.consensus.bftsmart.BftsmartNodeConfig)1 BftsmartNodeSettings (com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings)1 BftsmartNodeServer (com.jd.blockchain.consensus.bftsmart.service.BftsmartNodeServer)1 BftsmartServerSettingConfig (com.jd.blockchain.consensus.bftsmart.service.BftsmartServerSettingConfig)1 PubKey (com.jd.blockchain.crypto.PubKey)1 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)1 MemoryStorage (utils.io.MemoryStorage)1 NetworkAddress (utils.net.NetworkAddress)1