Skip to content

Commit

Permalink
[FAB-9850] Remove identity from channel cfg cache key
Browse files Browse the repository at this point in the history
Channel configurations retrieved by different identities
are the same so there is no need to create a new cache
value if identity changes.

Change-Id: Ie731217b28aed6e9d4b87d2418f24ee3b71b536f
Signed-off-by: Divyank Katira <Divyank.Katira@securekey.com>
  • Loading branch information
d1vyank committed May 2, 2018
1 parent 0404e72 commit 56ed3fe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
15 changes: 1 addition & 14 deletions pkg/fab/chconfig/cache.go
Expand Up @@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
package chconfig

import (
"crypto/sha256"
"time"

"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
Expand Down Expand Up @@ -37,20 +36,8 @@ type cacheKey struct {

// NewCacheKey returns a new CacheKey
func NewCacheKey(ctx fab.ClientContext, pvdr Provider, channelID string) (CacheKey, error) {
identity, err := ctx.Serialize()
if err != nil {
return nil, err
}

h := sha256.New()
_, err = h.Write(identity)
if err != nil {
return nil, err
}
hash := h.Sum([]byte(channelID))

return &cacheKey{
key: string(hash),
key: channelID,
channelID: channelID,
context: ctx,
pvdr: pvdr,
Expand Down
2 changes: 1 addition & 1 deletion pkg/fab/chconfig/chconfig_test.go
Expand Up @@ -127,7 +127,7 @@ func TestChannelConfigWithOrdererError(t *testing.T) {
t.Fatalf("Failed to create new channel client: %s", err)
}

reqCtx, cancel := contextImpl.NewRequest(ctx, contextImpl.WithTimeout(10*time.Second))
reqCtx, cancel := contextImpl.NewRequest(ctx, contextImpl.WithTimeout(1*time.Second))
defer cancel()

// Expecting error since orderer is not setup
Expand Down
2 changes: 1 addition & 1 deletion pkg/fab/endpointconfig.go
Expand Up @@ -50,7 +50,7 @@ const (
defaultDiscoveryResponseTimeout = time.Second * 15
defaultConnIdleInterval = time.Second * 30
defaultEventServiceIdleInterval = time.Minute * 2
defaultChannelConfigRefreshInterval = time.Minute * 90
defaultChannelConfigRefreshInterval = time.Second * 90
defaultChannelMemshpRefreshInterval = time.Second * 60
defaultDiscoveryRefreshInterval = time.Second * 10

Expand Down

0 comments on commit 56ed3fe

Please sign in to comment.