Skip to content

Commit

Permalink
[FAB-9578] ConfigSequence support ignore empty channel
Browse files Browse the repository at this point in the history
This change set makes the config support ignore empty channels
and just always return 0.

This is needed because the auth cache for local (channel-less) queries
uses config sequences to know when to clear its cache.

Change-Id: Ie6c0ee4dacf9e283e3f4e1c06f25eb74713344b1
Signed-off-by: yacovm <[email protected]>
  • Loading branch information
yacovm committed Apr 18, 2018
1 parent 3d1631d commit ad522a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions discovery/support/acl/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (s *DiscoverySupport) EligibleForService(channel string, data common2.Signe

// ConfigSequence returns the configuration sequence of the given channel
func (s *DiscoverySupport) ConfigSequence(channel string) uint64 {
// No sequence if the channel is empty
if channel == "" {
return 0
}
conf := s.GetChannelConfig(channel)
if conf == nil {
logger.Panic("Failed obtaining channel config for channel", channel)
Expand Down
7 changes: 7 additions & 0 deletions discovery/support/acl/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func TestGetChannelConfigFunc(t *testing.T) {
assert.Equal(t, r, acl.ChannelConfigGetterFunc(f).GetChannelConfig("mychannel"))
}

func TestConfigSequenceEmptyChannelName(t *testing.T) {
// If the channel name is empty, there is no config sequence,
// and we return 0
sup := acl.NewDiscoverySupport(nil, nil, nil)
assert.Equal(t, uint64(0), sup.ConfigSequence(""))
}

func TestConfigSequence(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit ad522a5

Please sign in to comment.