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

Function UpdateConfig

integration/nwo/configblock.go:83–167  ·  view source on GitHub ↗

UpdateConfig computes, signs, and submits a configuration update and waits for the update to complete.

(n *Network, orderer *Orderer, channel string, current, updated *common.Config, getConfigBlockFromOrderer bool, submitter *Peer, ordererSigners []*Orderer, additionalSigners ...*Peer)

Source from the content-addressed store, hash-verified

81// UpdateConfig computes, signs, and submits a configuration update and waits
82// for the update to complete.
83func UpdateConfig(n *Network, orderer *Orderer, channel string, current, updated *common.Config, getConfigBlockFromOrderer bool, submitter *Peer, ordererSigners []*Orderer, additionalSigners ...*Peer) {
84 tempDir, err := os.MkdirTemp("", "updateConfig")
85 Expect(err).NotTo(HaveOccurred())
86 defer os.RemoveAll(tempDir)
87
88 // compute update
89 configUpdate, err := update.Compute(current, updated)
90 Expect(err).NotTo(HaveOccurred())
91 configUpdate.ChannelId = channel
92
93 signedEnvelope, err := protoutil.CreateSignedEnvelope(
94 common.HeaderType_CONFIG_UPDATE,
95 channel,
96 nil, // local signer
97 &common.ConfigUpdateEnvelope{ConfigUpdate: protoutil.MarshalOrPanic(configUpdate)},
98 0, // message version
99 0, // epoch
100 )
101 Expect(err).NotTo(HaveOccurred())
102 Expect(signedEnvelope).NotTo(BeNil())
103
104 updateFile := filepath.Join(tempDir, "update.pb")
105 err = os.WriteFile(updateFile, protoutil.MarshalOrPanic(signedEnvelope), 0o600)
106 Expect(err).NotTo(HaveOccurred())
107
108 for _, signer := range additionalSigners {
109 sess, err := n.PeerAdminSession(signer, commands.SignConfigTx{
110 File: updateFile,
111 ClientAuth: n.ClientAuthRequired,
112 })
113 Expect(err).NotTo(HaveOccurred())
114 Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
115 }
116
117 for _, signer := range ordererSigners {
118 sess, err := n.OrdererAdminSession(signer, submitter, commands.SignConfigTx{
119 File: updateFile,
120 ClientAuth: n.ClientAuthRequired,
121 })
122 Expect(err).NotTo(HaveOccurred())
123 Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
124 }
125
126 sess, err := n.PeerAdminSession(submitter, commands.SignConfigTx{
127 File: updateFile,
128 ClientAuth: n.ClientAuthRequired,
129 })
130 Expect(err).NotTo(HaveOccurred())
131 Eventually(sess, n.EventuallyTimeout).Should(gexec.Exit(0))
132
133 var currentBlockNumber uint64
134 // get current configuration block number
135 if getConfigBlockFromOrderer {
136 currentBlockNumber = CurrentConfigBlockNumber(n, submitter, orderer, channel)
137 } else {
138 currentBlockNumber = CurrentConfigBlockNumber(n, submitter, nil, channel)
139 }
140

Callers 7

lifecycle_test.goFile · 0.92
discovery_test.goFile · 0.92
SetACLPolicyFunction · 0.92
EnableCapabilitiesFunction · 0.85
UpdateOrgAnchorPeersMethod · 0.85

Calls 12

ComputeFunction · 0.92
CreateSignedEnvelopeFunction · 0.92
MarshalOrPanicFunction · 0.92
CurrentConfigBlockNumberFunction · 0.85
RemoveAllMethod · 0.80
PeerAdminSessionMethod · 0.80
OrdererAdminSessionMethod · 0.80
PeersWithChannelMethod · 0.80
UpdateFunction · 0.70
WriteFileMethod · 0.65
ReadFileMethod · 0.65
UnmarshalMethod · 0.65

Tested by 2

SetACLPolicyFunction · 0.74