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