From d444f934f1edeeec53693b7085d044b105170168 Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Fri, 1 Apr 2022 22:26:26 +0000
Subject: [PATCH] Deduplicate the identity list

---
 backup/backup.go | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/backup/backup.go b/backup/backup.go
index 2e0eaab92..dafcb5f04 100644
--- a/backup/backup.go
+++ b/backup/backup.go
@@ -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
+}
-- 
GitLab