From 455c6afd341c66e8d3ee28e0e7c16ac450aef562 Mon Sep 17 00:00:00 2001
From: jbhusson <jonah@elixxir.io>
Date: Tue, 12 Oct 2021 12:55:58 -0400
Subject: [PATCH] Add a sync map for rounds received

---
 notifications/notifications.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/notifications/notifications.go b/notifications/notifications.go
index f500602..6bc04e6 100644
--- a/notifications/notifications.go
+++ b/notifications/notifications.go
@@ -11,6 +11,7 @@ package notifications
 import (
 	"encoding/base64"
 	"gitlab.com/elixxir/notifications-bot/notifications/apns"
+	"sync"
 
 	// "github.com/jonahh-yeti/apns"
 	"github.com/pkg/errors"
@@ -65,6 +66,7 @@ type Impl struct {
 	fcm         *firebase.FirebaseComm
 	apnsClient  *apns.ApnsComm
 	receivedNdf *uint32
+	roundStore  sync.Map
 
 	ndfStopper Stopper
 }
@@ -333,6 +335,13 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
 	//	return errors.New("Cannot receive notification data: client is not authenticated")
 	//}
 
+	rid := notifBatch.RoundID
+
+	_, loaded := nb.roundStore.LoadOrStore(rid, true)
+	if loaded {
+		return nil
+	}
+
 	jww.INFO.Printf("Received notification batch for round %+v", notifBatch.RoundID)
 
 	for _, notifData := range notifBatch.GetNotifications() {
-- 
GitLab