MCPcopy
hub / github.com/hyperledger/fabric / updateConfigWithNewCertsForPeer

Function updateConfigWithNewCertsForPeer

integration/pvtdata/pvtdata_test.go:1295–1331  ·  view source on GitHub ↗

updateConfigWithNewCertsForPeer updates the channel config with new certs for the designated peer

(network *nwo.Network, tempCryptoDir string, orderer *nwo.Orderer, peer *nwo.Peer)

Source from the content-addressed store, hash-verified

1293
1294// updateConfigWithNewCertsForPeer updates the channel config with new certs for the designated peer
1295func updateConfigWithNewCertsForPeer(network *nwo.Network, tempCryptoDir string, orderer *nwo.Orderer, peer *nwo.Peer) {
1296 org := network.Organization(peer.Organization)
1297
1298 By("fetching the channel policy")
1299 currentConfig := nwo.GetConfig(network, network.Peers[0], orderer, channelID)
1300 updatedConfig := proto.Clone(currentConfig).(*cb.Config)
1301
1302 By("parsing the old and new MSP configs")
1303 oldConfig := &mspp.MSPConfig{}
1304 err := proto.Unmarshal(
1305 updatedConfig.ChannelGroup.Groups["Application"].Groups[org.Name].Values["MSP"].Value,
1306 oldConfig,
1307 )
1308 Expect(err).NotTo(HaveOccurred())
1309
1310 tempOrgMSPPath := filepath.Join(tempCryptoDir, "peerOrganizations", org.Domain, "msp")
1311 newConfig, err := msp.GetVerifyingMspConfig(tempOrgMSPPath, org.MSPID, "bccsp")
1312 Expect(err).NotTo(HaveOccurred())
1313 oldMspConfig := &mspp.FabricMSPConfig{}
1314 newMspConfig := &mspp.FabricMSPConfig{}
1315 err = proto.Unmarshal(oldConfig.Config, oldMspConfig)
1316 Expect(err).NotTo(HaveOccurred())
1317 err = proto.Unmarshal(newConfig.Config, newMspConfig)
1318 Expect(err).NotTo(HaveOccurred())
1319
1320 By("merging the two MSP configs")
1321 updateOldMspConfigWithNewMspConfig(oldMspConfig, newMspConfig)
1322
1323 By("updating the channel config")
1324 updatedConfig.ChannelGroup.Groups["Application"].Groups[org.Name].Values["MSP"].Value = protoutil.MarshalOrPanic(
1325 &mspp.MSPConfig{
1326 Type: oldConfig.Type,
1327 Config: protoutil.MarshalOrPanic(oldMspConfig),
1328 },
1329 )
1330 nwo.UpdateConfig(network, orderer, channelID, currentConfig, updatedConfig, false, network.Peer(org.Name, "peer0"), nil)
1331}
1332
1333// updateOldMspConfigWithNewMspConfig updates the oldMspConfig with certs from the newMspConfig
1334func updateOldMspConfigWithNewMspConfig(oldMspConfig, newMspConfig *mspp.FabricMSPConfig) {

Callers 1

pvtdata_test.goFile · 0.85

Calls 9

GetConfigFunction · 0.92
GetVerifyingMspConfigFunction · 0.92
MarshalOrPanicFunction · 0.92
UpdateConfigFunction · 0.92
OrganizationMethod · 0.80
CloneMethod · 0.65
UnmarshalMethod · 0.65
PeerMethod · 0.45

Tested by

no test coverage detected