Skip to content
Snippets Groups Projects

Add a sync map for rounds received

Merged Jonah Husson requested to merge jonah/receive-map into release
1 file
+ 15
1
Compare changes
  • Side-by-side
  • Inline
@@ -337,7 +337,7 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
@@ -337,7 +337,7 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
rid := notifBatch.RoundID
rid := notifBatch.RoundID
_, loaded := nb.roundStore.LoadOrStore(rid, true)
_, loaded := nb.roundStore.LoadOrStore(rid, time.Now())
if loaded {
if loaded {
return nil
return nil
}
}
@@ -357,3 +357,17 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
@@ -357,3 +357,17 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
func (nb *Impl) ReceivedNdf() *uint32 {
func (nb *Impl) ReceivedNdf() *uint32 {
return nb.receivedNdf
return nb.receivedNdf
}
}
 
 
func (nb *Impl) Cleaner() {
 
for {
 
f := func(key, val interface{}) bool {
 
t := val.(time.Time)
 
if time.Since(t) > (5 * time.Minute) {
 
nb.roundStore.Delete(key)
 
}
 
return true
 
}
 
nb.roundStore.Range(f)
 
time.Sleep(time.Minute * 10)
 
}
 
}
Loading