Search in sources :

Example 1 with Replica

use of com.jd.blockchain.consensus.Replica in project jdchain-core by blockchain-jd-com.

the class RaftConsensusSettingsBuilder method createSettings.

@Override
public ConsensusViewSettings createSettings(Properties props, Replica[] replicas) {
    RaftConsensusConfig raftConsensusConfig = new RaftConsensusConfig();
    List<NodeSettings> nodeSettings = new ArrayList<>(replicas.length);
    RaftConfig raftSettings = new RaftConfig();
    RaftNetworkConfig networkConfig = new RaftNetworkConfig();
    for (Replica replica : replicas) {
        RaftNodeConfig raftNodeSettings = new RaftNodeConfig();
        raftNodeSettings.init(props, replica);
        nodeSettings.add(raftNodeSettings);
    }
    raftSettings.init(props);
    networkConfig.init(props);
    raftConsensusConfig.init(props);
    raftConsensusConfig.setNodeSettingsList(nodeSettings);
    raftConsensusConfig.setRaftSettings(raftSettings);
    raftConsensusConfig.setNetworkSettings(networkConfig);
    return raftConsensusConfig;
}
Also used : NodeSettings(com.jd.blockchain.consensus.NodeSettings) RaftNodeSettings(com.jd.blockchain.consensus.raft.settings.RaftNodeSettings) Replica(com.jd.blockchain.consensus.Replica)

Aggregations

NodeSettings (com.jd.blockchain.consensus.NodeSettings)1 Replica (com.jd.blockchain.consensus.Replica)1 RaftNodeSettings (com.jd.blockchain.consensus.raft.settings.RaftNodeSettings)1