From ded05a882c78e94c0a5a8715eaaeda791e2009a1 Mon Sep 17 00:00:00 2001 From: manish Date: Wed, 2 May 2018 17:43:29 -0400 Subject: [PATCH] [FAB-9839] Fix pending comments for purge CRs This CR fixes a couple of minor comments that were skipped in the original CRs for saving efforts of rebasing etc. Change-Id: I0c3f0838ea69fe14baabbcc167c5223c51f72df9 Signed-off-by: manish --- core/ledger/kvledger/txmgmt/privacyenabledstate/db.go | 1 + core/ledger/kvledger/txmgmt/privacyenabledstate/db_test.go | 2 ++ core/ledger/pvtdatapolicy/btlpolicy.go | 4 ++-- core/ledger/pvtdatapolicy/btlpolicy_test.go | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/ledger/kvledger/txmgmt/privacyenabledstate/db.go b/core/ledger/kvledger/txmgmt/privacyenabledstate/db.go index e66c3e819fd..6f12a1a670b 100644 --- a/core/ledger/kvledger/txmgmt/privacyenabledstate/db.go +++ b/core/ledger/kvledger/txmgmt/privacyenabledstate/db.go @@ -186,6 +186,7 @@ func (p PvtUpdateBatch) ToCompositeKeyMap() map[PvtdataCompositeKey]*statedb.Ver return m } +// String returns a print friendly form of HashedCompositeKey func (hck *HashedCompositeKey) String() string { return fmt.Sprintf("ns=%s, collection=%s, keyHash=%x", hck.Namespace, hck.CollectionName, hck.KeyHash) } diff --git a/core/ledger/kvledger/txmgmt/privacyenabledstate/db_test.go b/core/ledger/kvledger/txmgmt/privacyenabledstate/db_test.go index ec2cf53be30..967653bd683 100644 --- a/core/ledger/kvledger/txmgmt/privacyenabledstate/db_test.go +++ b/core/ledger/kvledger/txmgmt/privacyenabledstate/db_test.go @@ -403,6 +403,8 @@ func TestCompositeKeyMap(t *testing.T) { testutil.AssertEquals(t, ok, true) _, ok = m[PvtdataCompositeKey{"ns2", "coll2", "key2"}] testutil.AssertEquals(t, ok, true) + _, ok = m[PvtdataCompositeKey{"ns2", "coll1", "key8888"}] + testutil.AssertEquals(t, ok, false) } func putPvtUpdates(t *testing.T, updates *UpdateBatch, ns, coll, key string, value []byte, ver *version.Height) { diff --git a/core/ledger/pvtdatapolicy/btlpolicy.go b/core/ledger/pvtdatapolicy/btlpolicy.go index 225e4d93f1b..2e40abb34a2 100644 --- a/core/ledger/pvtdatapolicy/btlpolicy.go +++ b/core/ledger/pvtdatapolicy/btlpolicy.go @@ -16,7 +16,7 @@ import ( "github.com/hyperledger/fabric/protos/common" ) -var defaultBLT uint64 = math.MaxUint64 +var defaultBTL uint64 = math.MaxUint64 // BTLPolicy BlockToLive policy for the pvt data type BTLPolicy interface { @@ -70,7 +70,7 @@ func (p *LSCCBasedBTLPolicy) GetBTL(namesapce string, collection string) (uint64 if btlConfigured > 0 { btl = uint64(btlConfigured) } else { - btl = defaultBLT + btl = defaultBTL } p.cache[key] = btl } diff --git a/core/ledger/pvtdatapolicy/btlpolicy_test.go b/core/ledger/pvtdatapolicy/btlpolicy_test.go index a88ceece1de..3b7a4605e6f 100644 --- a/core/ledger/pvtdatapolicy/btlpolicy_test.go +++ b/core/ledger/pvtdatapolicy/btlpolicy_test.go @@ -31,7 +31,7 @@ func TestBTLPolicy(t *testing.T) { btl3, err := btlPolicy.GetBTL("ns1", "coll3") assert.NoError(t, err) - assert.Equal(t, defaultBLT, btl3) + assert.Equal(t, defaultBTL, btl3) _, err = btlPolicy.GetBTL("ns1", "coll4") _, ok := err.(privdata.NoSuchCollectionError)