Skip to content

Commit

Permalink
[FAB-8872] copy GRPC options in matchers
Browse files Browse the repository at this point in the history
Change-Id: I0aec7d9db0cdb3747225654eb3ed091d13b4c191
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Mar 15, 2018
1 parent 05c52e8 commit 59fa8aa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/core/config/config.go
Expand Up @@ -803,6 +803,10 @@ func (c *Config) tryMatchingPeerConfig(peerName string) (*core.PeerConfig, error
if !ok {
return nil, errors.WithMessage(err, "failed to load config from matched Peer")
}

// Make a copy of GRPC options (as it is manipulated below)
peerConfig.GRPCOptions = copyPropertiesMap(peerConfig.GRPCOptions)

_, isPortPresentInPeerName := c.getPortIfPresent(peerName)
//if substitution url is empty, use the same network peer url
if peerMatchConfig.URLSubstitutionExp == "" {
Expand Down Expand Up @@ -900,6 +904,10 @@ func (c *Config) tryMatchingOrdererConfig(ordererName string) (*core.OrdererConf
if !ok {
return nil, errors.WithMessage(err, "failed to load config from matched Orderer")
}

// Make a copy of GRPC options (as it is manipulated below)
ordererConfig.GRPCOptions = copyPropertiesMap(ordererConfig.GRPCOptions)

_, isPortPresentInOrdererName := c.getPortIfPresent(ordererName)
//if substitution url is empty, use the same network orderer url
if ordererMatchConfig.URLSubstitutionExp == "" {
Expand Down Expand Up @@ -950,6 +958,14 @@ func (c *Config) tryMatchingOrdererConfig(ordererName string) (*core.OrdererConf
return nil, errors.New("no matching orderer config found")
}

func copyPropertiesMap(origMap map[string]interface{}) map[string]interface{} {
newMap := make(map[string]interface{}, len(origMap))
for k, v := range origMap {
newMap[k] = v
}
return newMap
}

func (c *Config) findMatchingPeer(peerName string) (string, error) {
networkConfig, err := c.NetworkConfig()
if err != nil {
Expand Down

0 comments on commit 59fa8aa

Please sign in to comment.