github.com/kaituanwang/hyperledger@v2.0.1+incompatible/common/tools/protolator/protoext/mspext/msp_config.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package mspext 8 9 import ( 10 "fmt" 11 12 "github.com/golang/protobuf/proto" 13 "github.com/hyperledger/fabric-protos-go/msp" 14 ) 15 16 type MSPConfig struct{ *msp.MSPConfig } 17 18 func (mc *MSPConfig) Underlying() proto.Message { 19 return mc.MSPConfig 20 } 21 22 func (mc *MSPConfig) VariablyOpaqueFields() []string { 23 return []string{"config"} 24 } 25 26 func (mc *MSPConfig) VariablyOpaqueFieldProto(name string) (proto.Message, error) { 27 if name != mc.VariablyOpaqueFields()[0] { 28 return nil, fmt.Errorf("not a marshaled field: %s", name) 29 } 30 switch mc.Type { 31 case 0: 32 return &msp.FabricMSPConfig{}, nil 33 case 1: 34 return &msp.IdemixMSPConfig{}, nil 35 default: 36 return nil, fmt.Errorf("unable to decode MSP type: %v", mc.Type) 37 } 38 }