Search in sources :

Example 1 with ConfigGroup

use of org.hyperledger.fabric.protos.common.Configtx.ConfigGroup in project fabric-sdk-java by hyperledger.

the class Channel method parseConfigBlock.

protected void parseConfigBlock() throws TransactionException {
    Map<String, MSP> lmsps = msps;
    if (lmsps != null && !lmsps.isEmpty()) {
        return;
    }
    try {
        Block parseFrom = getConfigBlock(getShuffledPeers());
        // final Block configBlock = getConfigurationBlock();
        logger.debug(format("Channel %s Got config block getting MSP data and anchorPeers data", name));
        Envelope envelope = Envelope.parseFrom(parseFrom.getData().getData(0));
        Payload payload = Payload.parseFrom(envelope.getPayload());
        ConfigEnvelope configEnvelope = ConfigEnvelope.parseFrom(payload.getData());
        ConfigGroup channelGroup = configEnvelope.getConfig().getChannelGroup();
        Map<String, MSP> newMSPS = traverseConfigGroupsMSP("", channelGroup, new HashMap<>(20));
        msps = Collections.unmodifiableMap(newMSPS);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new TransactionException(e);
    }
}
Also used : TransactionException(org.hyperledger.fabric.sdk.exception.TransactionException) ConfigEnvelope(org.hyperledger.fabric.protos.common.Configtx.ConfigEnvelope) Block(org.hyperledger.fabric.protos.common.Common.Block) Payload(org.hyperledger.fabric.protos.common.Common.Payload) ProtoUtils.getSignatureHeaderAsByteString(org.hyperledger.fabric.sdk.transaction.ProtoUtils.getSignatureHeaderAsByteString) ByteString(com.google.protobuf.ByteString) ConfigEnvelope(org.hyperledger.fabric.protos.common.Configtx.ConfigEnvelope) ConfigUpdateEnvelope(org.hyperledger.fabric.protos.common.Configtx.ConfigUpdateEnvelope) Envelope(org.hyperledger.fabric.protos.common.Common.Envelope) ProtoUtils.createSeekInfoEnvelope(org.hyperledger.fabric.sdk.transaction.ProtoUtils.createSeekInfoEnvelope) ConfigGroup(org.hyperledger.fabric.protos.common.Configtx.ConfigGroup) EventHubException(org.hyperledger.fabric.sdk.exception.EventHubException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) InvalidArgumentException(org.hyperledger.fabric.sdk.exception.InvalidArgumentException) TransactionException(org.hyperledger.fabric.sdk.exception.TransactionException) TransactionEventException(org.hyperledger.fabric.sdk.exception.TransactionEventException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) StatusRuntimeException(io.grpc.StatusRuntimeException) CryptoException(org.hyperledger.fabric.sdk.exception.CryptoException) TimeoutException(java.util.concurrent.TimeoutException) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException)

Example 2 with ConfigGroup

use of org.hyperledger.fabric.protos.common.Configtx.ConfigGroup in project fabric-sdk-java by hyperledger.

the class Channel method traverseConfigGroupsMSP.

private Map<String, MSP> traverseConfigGroupsMSP(String name, ConfigGroup configGroup, Map<String, MSP> msps) throws InvalidProtocolBufferException {
    ConfigValue mspv = configGroup.getValuesMap().get("MSP");
    if (null != mspv) {
        if (!msps.containsKey(name)) {
            MspConfig.MSPConfig mspConfig = MspConfig.MSPConfig.parseFrom(mspv.getValue());
            MspConfig.FabricMSPConfig fabricMSPConfig = MspConfig.FabricMSPConfig.parseFrom(mspConfig.getConfig());
            msps.put(name, new MSP(name, fabricMSPConfig));
        }
    }
    for (Map.Entry<String, ConfigGroup> gm : configGroup.getGroupsMap().entrySet()) {
        traverseConfigGroupsMSP(gm.getKey(), gm.getValue(), msps);
    }
    return msps;
}
Also used : ConfigValue(org.hyperledger.fabric.protos.common.Configtx.ConfigValue) MspConfig(org.hyperledger.fabric.protos.msp.MspConfig) ProtoUtils.getSignatureHeaderAsByteString(org.hyperledger.fabric.sdk.transaction.ProtoUtils.getSignatureHeaderAsByteString) ByteString(com.google.protobuf.ByteString) ConfigGroup(org.hyperledger.fabric.protos.common.Configtx.ConfigGroup) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Aggregations

ByteString (com.google.protobuf.ByteString)2 ConfigGroup (org.hyperledger.fabric.protos.common.Configtx.ConfigGroup)2 ProtoUtils.getSignatureHeaderAsByteString (org.hyperledger.fabric.sdk.transaction.ProtoUtils.getSignatureHeaderAsByteString)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Block (org.hyperledger.fabric.protos.common.Common.Block)1 Envelope (org.hyperledger.fabric.protos.common.Common.Envelope)1 Payload (org.hyperledger.fabric.protos.common.Common.Payload)1 ConfigEnvelope (org.hyperledger.fabric.protos.common.Configtx.ConfigEnvelope)1 ConfigUpdateEnvelope (org.hyperledger.fabric.protos.common.Configtx.ConfigUpdateEnvelope)1 ConfigValue (org.hyperledger.fabric.protos.common.Configtx.ConfigValue)1 MspConfig (org.hyperledger.fabric.protos.msp.MspConfig)1 CryptoException (org.hyperledger.fabric.sdk.exception.CryptoException)1 EventHubException (org.hyperledger.fabric.sdk.exception.EventHubException)1