diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 22bb990..1412a59 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ## Changed +- After a SVS `Core` exits `Suppression` state, more efficiently detect if a Sync Interest needs to be sent. - De-interface small simple structures: `MissingData` and `StatusChange`. - Reorganized functions to match interface method order. - Changed naming of a constant variable to be more consistent with others that function the same. diff --git a/pkg/svs/twostate_core.go b/pkg/svs/twostate_core.go index a1fcdeb..0322f3e 100644 --- a/pkg/svs/twostate_core.go +++ b/pkg/svs/twostate_core.go @@ -258,20 +258,19 @@ func (c *twoStateCore) recordVector(vector StateVector) { } func (c *twoStateCore) mergeRecordToLocal() bool { - var isNewer bool c.localMtx.Lock() - for p := c.record.Entries().Back(); p != nil; p = p.Prev() { + defer c.localMtx.Unlock() + if c.record.Len() < c.local.Len() { + return true + } + for p := c.record.Entries().Front(); p != nil; p = p.Next() { if c.local.Get(p.Kstr) > p.Val && !slices.Contains(c.selfsets, p.Kstr) { if !c.effSuppress || time.Since(c.updateTimes[p.Kstr]) >= c.constants.SuppressionInterval { - isNewer = true + return true } } } - if c.record.Len() < c.local.Len() { - isNewer = true - } - c.localMtx.Unlock() - return isNewer + return false } func suppressionDelay(val time.Duration, jitter float32) time.Duration {