Search in sources :

Example 1 with ConsensusProvider

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

the class GatewayQueryServiceHandler method initConsensusSettings.

/**
 * 初始化共识配置
 *
 * @param ledgerAdminInfo 账本元数据
 * @return
 */
private ConsensusViewSettings initConsensusSettings(LedgerAdminInfo ledgerAdminInfo) {
    String consensusProvider = ledgerAdminInfo.getSettings().getConsensusProvider();
    ConsensusProvider provider = ConsensusProviders.getProvider(consensusProvider);
    byte[] consensusSettingsBytes = ledgerAdminInfo.getSettings().getConsensusSetting().toBytes();
    return consensusSettingsDecorator(provider.getSettingsFactory().getConsensusSettingsEncoder().decode(consensusSettingsBytes));
}
Also used : ConsensusProvider(com.jd.blockchain.consensus.ConsensusProvider)

Example 2 with ConsensusProvider

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

the class LedgerInitConfiguration method createConsensusConfig.

private static ConsensusConfig createConsensusConfig(LedgerInitProperties initProps) {
    ConsensusProvider consensusProvider = ConsensusProviders.getProvider(initProps.getConsensusProvider());
    Properties csProps = initProps.getConsensusConfig();
    ConsensusViewSettings protocolSettings = consensusProvider.getSettingsFactory().getConsensusSettingsBuilder().createSettings(csProps, ParticipantReplica.wrap(initProps.getConsensusParticipantNodes()));
    ConsensusConfig config = new ConsensusConfig();
    config.setProvider(consensusProvider);
    config.setProtocolSettings(protocolSettings);
    return config;
}
Also used : ConsensusViewSettings(com.jd.blockchain.consensus.ConsensusViewSettings) ConsensusProvider(com.jd.blockchain.consensus.ConsensusProvider) LedgerInitProperties(com.jd.blockchain.ledger.LedgerInitProperties) ParticipantProperties(com.jd.blockchain.ledger.LedgerInitProperties.ParticipantProperties) Properties(java.util.Properties) CryptoProperties(com.jd.blockchain.ledger.LedgerInitProperties.CryptoProperties)

Example 3 with ConsensusProvider

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

the class IParticipantManagerService method getConsensusSetting.

default ConsensusViewSettings getConsensusSetting(ParticipantContext context) {
    ConsensusProvider provider = ConsensusProviders.getProvider(context.provider());
    Bytes csSettingBytes = context.ledgerAdminInfo().getSettings().getConsensusSetting();
    return provider.getSettingsFactory().getConsensusSettingsEncoder().decode(csSettingBytes.toBytes());
}
Also used : Bytes(utils.Bytes) ConsensusProvider(com.jd.blockchain.consensus.ConsensusProvider)

Aggregations

ConsensusProvider (com.jd.blockchain.consensus.ConsensusProvider)3 ConsensusViewSettings (com.jd.blockchain.consensus.ConsensusViewSettings)1 LedgerInitProperties (com.jd.blockchain.ledger.LedgerInitProperties)1 CryptoProperties (com.jd.blockchain.ledger.LedgerInitProperties.CryptoProperties)1 ParticipantProperties (com.jd.blockchain.ledger.LedgerInitProperties.ParticipantProperties)1 Properties (java.util.Properties)1 Bytes (utils.Bytes)1