Skip to content
Snippets Groups Projects
Commit d444f934 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Deduplicate the identity list

parent 7b874e48
No related branches found
No related tags found
3 merge requests!233Modify restore to call user-defined bindings callback. Add Sent requests to...,!231Revert "Update store to print changes to the partners list",!192Hotfix/improved restore
......@@ -24,6 +24,7 @@ import (
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/crypto/backup"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/primitives/id"
)
// Error messages.
......@@ -307,9 +308,23 @@ func (b *Backup) assembleBackup() backup.Backup {
// not yet noticed by user OR explicitly rejected.
bu.Contacts.Identities = append(bu.Contacts.Identities,
b.store.Auth().GetAllSentIDs()...)
//deduplicate list
bu.Contacts.Identities = deduplicate(bu.Contacts.Identities)
//add the memoized json params
bu.JSONParams = b.jsonParams
return bu
}
func deduplicate(list []*id.ID) []*id.ID {
entryMap := make(map[id.ID]bool)
newList := make([]*id.ID, 0)
for _, entry := range list {
if _, value := entryMap[*entry]; !value {
entryMap[*entry] = true
newList = append(newList, entry)
}
}
return newList
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment