Skip to content
Snippets Groups Projects
Commit 7b5a9d11 authored by Jonah Husson's avatar Jonah Husson
Browse files

Add cleaner func

parent 455c6afd
No related branches found
No related tags found
2 merge requests!12Release,!9Add a sync map for rounds received
......@@ -337,7 +337,7 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
rid := notifBatch.RoundID
_, loaded := nb.roundStore.LoadOrStore(rid, true)
_, loaded := nb.roundStore.LoadOrStore(rid, time.Now())
if loaded {
return nil
}
......@@ -357,3 +357,17 @@ func (nb *Impl) ReceiveNotificationBatch(notifBatch *pb.NotificationBatch, auth
func (nb *Impl) ReceivedNdf() *uint32 {
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)
}
}
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