Commit 84f72fa9 authored by Praful Nalatwad's avatar Praful Nalatwad
Browse files

rewamp GetAllKeysData method

parent dbf95942
Branches
Tags
3 merge requests!270Core ImmuDB package and TOTP plugin - Implementation,!269Core ImmuDB package and TOTP plugin - Implementation,!261rewamp GetAllKeysData method
Showing with 14 additions and 14 deletions
......@@ -265,31 +265,31 @@ func (i *ImmuDAO) GetVerifiedKeyData(key []byte) (*schema.Entry, error) {
}
// GetAllKeysData - Getting all keys data
func (i *ImmuDAO) GetAllKeysData(keys [][]byte) ([]string, *schema.Entries, error) {
/*
GetAllKeysData retrives value for provided keys,
values will be nil, for those keys which are not present in immudb
*/
func (i *ImmuDAO) GetAllKeysData(keys [][]byte) (*schema.Entries, error) {
client, err := GetImmuDbConnection(i.HostName) // ImmuDB connection for the provided host
if err != nil {
return nil, nil, err
return nil, err
}
result, err := client.GetAll(context.TODO(), keys)
if err != nil {
return nil, nil, err
return nil, err
}
//converting and storing keys ([][]bytes) to []string
keyString := []string{}
for _, v := range keys {
keyString = append(keyString, string(v))
mapEntries := make(map[string]interface{})
for _, val := range result.Entries {
mapEntries[string(val.Key)] = val.Value
}
for i := 0; i < len(keyString); i++ {
for j := 0; j < len(result.Entries); j++ {
if keyString[i] == string(result.Entries[j].Key) {
//appending keys whose value not found in Immudb
keyString = append(keyString[:i], keyString[i+1:]...)
}
for _, key := range keys {
if _, ok := mapEntries[string(key)]; !ok {
result.Entries = append(result.Entries, &schema.Entry{Key: key, Value: nil})
}
}
return keyString, result, nil
return result, nil
}
// GetKeyHistory - Get history of single key
......
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