Skip to content

Commit

Permalink
[FAB-17950] Implement removal of orderer endpoints from toplevel chan…
Browse files Browse the repository at this point in the history
…nel (#29)

config

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
  • Loading branch information
stephyee authored Jun 11, 2020
1 parent 981ce73 commit 822f633
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions configtx/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,11 @@ func (c *ChannelGroup) RemoveCapability(capability string) error {

return nil
}

// RemoveLegacyOrdererAddresses removes the deprecated top level orderer addresses config key and value
// from the channel config.
// In fabric 1.4, top level orderer addresses were migrated to the org level orderer endpoints
// While top-level orderer addresses are still supported, the organization value is preferred.
func (c *ChannelGroup) RemoveLegacyOrdererAddresses() {
delete(c.channelGroup.Values, OrdererAddressesKey)
}
25 changes: 25 additions & 0 deletions configtx/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,28 @@ func TestRemoveChannelPolicyFailures(t *testing.T) {
err = c.Channel().RemovePolicy(ReadersPolicyKey)
gt.Expect(err).To(MatchError("unknown policy type: 15"))
}

func TestRemoveLegacyOrdererAddresses(t *testing.T) {
t.Parallel()
gt := NewGomegaWithT(t)

config := &cb.Config{
ChannelGroup: &cb.ConfigGroup{
Values: map[string]*cb.ConfigValue{
OrdererAddressesKey: {
ModPolicy: AdminsPolicyKey,
Value: marshalOrPanic(&cb.OrdererAddresses{
Addresses: []string{"127.0.0.1:8050"},
}),
},
},
},
}

c := New(config)

c.Channel().RemoveLegacyOrdererAddresses()

_, exists := c.Channel().channelGroup.Values[OrdererAddressesKey]
gt.Expect(exists).To(BeFalse())
}
3 changes: 3 additions & 0 deletions configtx/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@ const (
SignaturePolicyType = "Signature"

ordererAdminsPolicyName = "/Channel/Orderer/Admins"

// OrdererAddressesKey is the key for the ConfigValue of OrdererAddresses.
OrdererAddressesKey = "OrdererAddresses"
)

0 comments on commit 822f633

Please sign in to comment.