Commit 7dcd45c8 authored by manish's avatar manish
Browse files

FAB-12070 - Fix typo in versionedDB interface



Change-Id: Icea248ca21a6b2e163322fb04b86bd4fac7c6df2
Signed-off-by: default avatarmanish <manish.sethi@gmail.com>
parent 7851d469
......@@ -99,7 +99,7 @@ func (s *CommonStorageDB) LoadCommittedVersionsOfPubAndHashedKeys(pubKeys []*sta
ns := deriveHashedDataNs(key.Namespace, key.CollectionName)
// No need to check for duplicates as hashedKeys are in separate namespace
var keyHashStr string
if !s.BytesKeySuppoted() {
if !s.BytesKeySupported() {
keyHashStr = base64.StdEncoding.EncodeToString([]byte(key.KeyHash))
} else {
keyHashStr = key.KeyHash
......@@ -143,7 +143,7 @@ func (s *CommonStorageDB) GetPrivateData(namespace, collection, key string) (*st
// GetValueHash implements corresponding function in interface DB
func (s *CommonStorageDB) GetValueHash(namespace, collection string, keyHash []byte) (*statedb.VersionedValue, error) {
keyHashStr := string(keyHash)
if !s.BytesKeySuppoted() {
if !s.BytesKeySupported() {
keyHashStr = base64.StdEncoding.EncodeToString(keyHash)
}
return s.GetState(deriveHashedDataNs(namespace, collection), keyHashStr)
......@@ -152,7 +152,7 @@ func (s *CommonStorageDB) GetValueHash(namespace, collection string, keyHash []b
// GetKeyHashVersion implements corresponding function in interface DB
func (s *CommonStorageDB) GetKeyHashVersion(namespace, collection string, keyHash []byte) (*version.Height, error) {
keyHashStr := string(keyHash)
if !s.BytesKeySuppoted() {
if !s.BytesKeySupported() {
keyHashStr = base64.StdEncoding.EncodeToString(keyHash)
}
return s.GetVersion(deriveHashedDataNs(namespace, collection), keyHashStr)
......@@ -166,7 +166,7 @@ func (s *CommonStorageDB) GetCachedKeyHashVersion(namespace, collection string,
}
keyHashStr := string(keyHash)
if !s.BytesKeySuppoted() {
if !s.BytesKeySupported() {
keyHashStr = base64.StdEncoding.EncodeToString(keyHash)
}
return bulkOptimizable.GetCachedVersion(deriveHashedDataNs(namespace, collection), keyHashStr)
......@@ -198,7 +198,7 @@ func (s *CommonStorageDB) ApplyPrivacyAwareUpdates(updates *UpdateBatch, height
// combinedUpdates includes both updates to public db and private db, which are partitioned by a separate namespace
combinedUpdates := updates.PubUpdates
addPvtUpdates(combinedUpdates, updates.PvtUpdates)
addHashedUpdates(combinedUpdates, updates.HashUpdates, !s.BytesKeySuppoted())
addHashedUpdates(combinedUpdates, updates.HashUpdates, !s.BytesKeySupported())
s.metadataHint.setMetadataUsedFlag(updates)
return s.VersionedDB.ApplyUpdates(combinedUpdates.UpdateBatch, height)
}
......
......@@ -146,13 +146,13 @@ type VersionedDB struct {
validateKeyValueReturnsOnCall map[int]struct {
result1 error
}
BytesKeySuppotedStub func() bool
bytesKeySuppotedMutex sync.RWMutex
bytesKeySuppotedArgsForCall []struct{}
bytesKeySuppotedReturns struct {
BytesKeySupportedStub func() bool
bytesKeySupportedMutex sync.RWMutex
bytesKeySupportedArgsForCall []struct{}
bytesKeySupportedReturns struct {
result1 bool
}
bytesKeySuppotedReturnsOnCall map[int]struct {
bytesKeySupportedReturnsOnCall map[int]struct {
result1 bool
}
OpenStub func() error
......@@ -690,42 +690,42 @@ func (fake *VersionedDB) ValidateKeyValueReturnsOnCall(i int, result1 error) {
}{result1}
}
func (fake *VersionedDB) BytesKeySuppoted() bool {
fake.bytesKeySuppotedMutex.Lock()
ret, specificReturn := fake.bytesKeySuppotedReturnsOnCall[len(fake.bytesKeySuppotedArgsForCall)]
fake.bytesKeySuppotedArgsForCall = append(fake.bytesKeySuppotedArgsForCall, struct{}{})
fake.recordInvocation("BytesKeySuppoted", []interface{}{})
fake.bytesKeySuppotedMutex.Unlock()
if fake.BytesKeySuppotedStub != nil {
return fake.BytesKeySuppotedStub()
func (fake *VersionedDB) BytesKeySupported() bool {
fake.bytesKeySupportedMutex.Lock()
ret, specificReturn := fake.bytesKeySupportedReturnsOnCall[len(fake.bytesKeySupportedArgsForCall)]
fake.bytesKeySupportedArgsForCall = append(fake.bytesKeySupportedArgsForCall, struct{}{})
fake.recordInvocation("BytesKeySupported", []interface{}{})
fake.bytesKeySupportedMutex.Unlock()
if fake.BytesKeySupportedStub != nil {
return fake.BytesKeySupportedStub()
}
if specificReturn {
return ret.result1
}
return fake.bytesKeySuppotedReturns.result1
return fake.bytesKeySupportedReturns.result1
}
func (fake *VersionedDB) BytesKeySuppotedCallCount() int {
fake.bytesKeySuppotedMutex.RLock()
defer fake.bytesKeySuppotedMutex.RUnlock()
return len(fake.bytesKeySuppotedArgsForCall)
func (fake *VersionedDB) BytesKeySupportedCallCount() int {
fake.bytesKeySupportedMutex.RLock()
defer fake.bytesKeySupportedMutex.RUnlock()
return len(fake.bytesKeySupportedArgsForCall)
}
func (fake *VersionedDB) BytesKeySuppotedReturns(result1 bool) {
fake.BytesKeySuppotedStub = nil
fake.bytesKeySuppotedReturns = struct {
func (fake *VersionedDB) BytesKeySupportedReturns(result1 bool) {
fake.BytesKeySupportedStub = nil
fake.bytesKeySupportedReturns = struct {
result1 bool
}{result1}
}
func (fake *VersionedDB) BytesKeySuppotedReturnsOnCall(i int, result1 bool) {
fake.BytesKeySuppotedStub = nil
if fake.bytesKeySuppotedReturnsOnCall == nil {
fake.bytesKeySuppotedReturnsOnCall = make(map[int]struct {
func (fake *VersionedDB) BytesKeySupportedReturnsOnCall(i int, result1 bool) {
fake.BytesKeySupportedStub = nil
if fake.bytesKeySupportedReturnsOnCall == nil {
fake.bytesKeySupportedReturnsOnCall = make(map[int]struct {
result1 bool
})
}
fake.bytesKeySuppotedReturnsOnCall[i] = struct {
fake.bytesKeySupportedReturnsOnCall[i] = struct {
result1 bool
}{result1}
}
......@@ -809,8 +809,8 @@ func (fake *VersionedDB) Invocations() map[string][][]interface{} {
defer fake.getLatestSavePointMutex.RUnlock()
fake.validateKeyValueMutex.RLock()
defer fake.validateKeyValueMutex.RUnlock()
fake.bytesKeySuppotedMutex.RLock()
defer fake.bytesKeySuppotedMutex.RUnlock()
fake.bytesKeySupportedMutex.RLock()
defer fake.bytesKeySupportedMutex.RUnlock()
fake.openMutex.RLock()
defer fake.openMutex.RUnlock()
fake.closeMutex.RLock()
......
......@@ -218,8 +218,8 @@ func (vdb *VersionedDB) ValidateKeyValue(key string, value []byte) error {
return validateValue(value)
}
// BytesKeySuppoted implements method in VersionedDB interface
func (vdb *VersionedDB) BytesKeySuppoted() bool {
// BytesKeySupported implements method in VersionedDB interface
func (vdb *VersionedDB) BytesKeySupported() bool {
return false
}
......
......@@ -152,8 +152,8 @@ func TestUtilityFunctions(t *testing.T) {
db, err := env.DBProvider.GetDBHandle("testutilityfunctions")
assert.NoError(t, err)
// BytesKeySuppoted should be false for CouchDB
byteKeySupported := db.BytesKeySuppoted()
// BytesKeySupported should be false for CouchDB
byteKeySupported := db.BytesKeySupported()
assert.False(t, byteKeySupported)
// ValidateKeyValue should return nil for a valid key and value
......
......@@ -64,9 +64,9 @@ type VersionedDB interface {
// However, as of now, the both implementations of this function (leveldb and couchdb) are deterministic in returing an error
// i.e., an error is returned only if the key-value are found to be invalid for the underlying db
ValidateKeyValue(key string, value []byte) error
// BytesKeySuppoted returns true if the implementation (underlying db) supports the any bytes to be used as key.
// BytesKeySupported returns true if the implementation (underlying db) supports the any bytes to be used as key.
// For instance, leveldb supports any bytes for the key while the couchdb supports only valid utf-8 string
BytesKeySuppoted() bool
BytesKeySupported() bool
// Open opens the db
Open() error
// Close closes the db
......
......@@ -73,8 +73,8 @@ func (vdb *versionedDB) ValidateKeyValue(key string, value []byte) error {
return nil
}
// BytesKeySuppoted implements method in VersionedDB interface
func (vdb *versionedDB) BytesKeySuppoted() bool {
// BytesKeySupported implements method in VersionedDB interface
func (vdb *versionedDB) BytesKeySupported() bool {
return true
}
......
......@@ -111,8 +111,8 @@ func TestUtilityFunctions(t *testing.T) {
db, err := env.DBProvider.GetDBHandle("testutilityfunctions")
assert.NoError(t, err)
// BytesKeySuppoted should be true for goleveldb
byteKeySupported := db.BytesKeySuppoted()
// BytesKeySupported should be true for goleveldb
byteKeySupported := db.BytesKeySupported()
assert.True(t, byteKeySupported)
// ValidateKeyValue should return nil for a valid key and value
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment