Skip to content

Commit

Permalink
faster detection if a interest is needed after suppression
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin C Presley committed Feb 17, 2024
1 parent 763915d commit 4c33165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 7 additions & 8 deletions pkg/svs/twostate_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4c33165

Please sign in to comment.