Search in sources :

Example 1 with ConfigEnvelope

use of org.hyperledger.fabric.protos.common.Configtx.ConfigEnvelope 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 ConfigEnvelope

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

the class Channel method getChannelConfigurationBytes.

/**
 * Channel Configuration bytes. Bytes that can be used with configtxlator tool to upgrade the channel.
 * Convert to Json for editing  with:
 * {@code
 * <p>
 * curl -v   POST --data-binary @fooConfig http://host/protolator/decode/common.Config
 * <p>
 * }
 * See http://hyperledger-fabric.readthedocs.io/en/latest/configtxlator.html
 *
 * @return Channel configuration bytes.
 * @throws TransactionException
 */
public byte[] getChannelConfigurationBytes() throws TransactionException {
    try {
        final Block configBlock = getConfigBlock(getShuffledPeers());
        Envelope envelopeRet = Envelope.parseFrom(configBlock.getData().getData(0));
        Payload payload = Payload.parseFrom(envelopeRet.getPayload());
        ConfigEnvelope configEnvelope = ConfigEnvelope.parseFrom(payload.getData());
        return configEnvelope.getConfig().toByteArray();
    } catch (Exception 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) 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) 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)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 Block (org.hyperledger.fabric.protos.common.Common.Block)2 Envelope (org.hyperledger.fabric.protos.common.Common.Envelope)2 Payload (org.hyperledger.fabric.protos.common.Common.Payload)2 ConfigEnvelope (org.hyperledger.fabric.protos.common.Configtx.ConfigEnvelope)2 ConfigUpdateEnvelope (org.hyperledger.fabric.protos.common.Configtx.ConfigUpdateEnvelope)2 CryptoException (org.hyperledger.fabric.sdk.exception.CryptoException)2 EventHubException (org.hyperledger.fabric.sdk.exception.EventHubException)2 InvalidArgumentException (org.hyperledger.fabric.sdk.exception.InvalidArgumentException)2 ProposalException (org.hyperledger.fabric.sdk.exception.ProposalException)2 TransactionEventException (org.hyperledger.fabric.sdk.exception.TransactionEventException)2 TransactionException (org.hyperledger.fabric.sdk.exception.TransactionException)2 ProtoUtils.createSeekInfoEnvelope (org.hyperledger.fabric.sdk.transaction.ProtoUtils.createSeekInfoEnvelope)2 ByteString (com.google.protobuf.ByteString)1 ConfigGroup (org.hyperledger.fabric.protos.common.Configtx.ConfigGroup)1 ProtoUtils.getSignatureHeaderAsByteString (org.hyperledger.fabric.sdk.transaction.ProtoUtils.getSignatureHeaderAsByteString)1