Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 56ed3fe

Browse files
committed
[FAB-9850] Remove identity from channel cfg cache key
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>
1 parent 0404e72 commit 56ed3fe

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

pkg/fab/chconfig/cache.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77
package chconfig
88

99
import (
10-
"crypto/sha256"
1110
"time"
1211

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

3837
// NewCacheKey returns a new CacheKey
3938
func NewCacheKey(ctx fab.ClientContext, pvdr Provider, channelID string) (CacheKey, error) {
40-
identity, err := ctx.Serialize()
41-
if err != nil {
42-
return nil, err
43-
}
44-
45-
h := sha256.New()
46-
_, err = h.Write(identity)
47-
if err != nil {
48-
return nil, err
49-
}
50-
hash := h.Sum([]byte(channelID))
51-
5239
return &cacheKey{
53-
key: string(hash),
40+
key: channelID,
5441
channelID: channelID,
5542
context: ctx,
5643
pvdr: pvdr,

pkg/fab/chconfig/chconfig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func TestChannelConfigWithOrdererError(t *testing.T) {
127127
t.Fatalf("Failed to create new channel client: %s", err)
128128
}
129129

130-
reqCtx, cancel := contextImpl.NewRequest(ctx, contextImpl.WithTimeout(10*time.Second))
130+
reqCtx, cancel := contextImpl.NewRequest(ctx, contextImpl.WithTimeout(1*time.Second))
131131
defer cancel()
132132

133133
// Expecting error since orderer is not setup

pkg/fab/endpointconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const (
5050
defaultDiscoveryResponseTimeout = time.Second * 15
5151
defaultConnIdleInterval = time.Second * 30
5252
defaultEventServiceIdleInterval = time.Minute * 2
53-
defaultChannelConfigRefreshInterval = time.Minute * 90
53+
defaultChannelConfigRefreshInterval = time.Second * 90
5454
defaultChannelMemshpRefreshInterval = time.Second * 60
5555
defaultDiscoveryRefreshInterval = time.Second * 10
5656

0 commit comments

Comments
 (0)