satellite/reputation: Alter logic for hasReputationChanged

This change modifies "reputation change trigger" logic for dq and
suspension in order to:
* count only nil -> not-nil and not-nil -> nil as "reputation changes"
* do not count the timestamp updating (not-nil -> not-nil) as a
  reputation change

Change-Id: Ie57c97e80e5f3b368e2f2dc004e680a2f9416d1c
This commit is contained in:
Moby von Briesen 2023-02-03 16:01:00 -05:00
parent add3034b43
commit 395426977f

View File

@ -291,13 +291,10 @@ func hasReputationChanged(updated Info, current overlay.ReputationStatus, now ti
}
// statusChanged determines if the two given statuses are different.
// a status is considered "different" if it went from nil to not-nil, or not-nil to nil.
// if not-nil and the only difference is the time, this is considered "not changed".
func statusChanged(s1, s2 *time.Time) bool {
if s1 == nil && s2 == nil {
return false
} else if s1 != nil && s2 != nil {
return !s1.Equal(*s2)
}
return true
return (s1 == nil && s2 != nil) || (s1 != nil && s2 == nil)
}
// UpdateRequestToMutations transforms an UpdateRequest into the equivalent