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);
}
}
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);
}
}
Aggregations