feat(botfilter): add clientCache.pruneEventsLocked

This commit is contained in:
hoelee committed 2026-02-12 14:50:00 +08:00
1 parent a1332aac20
commit f9bc58409a
1 file changed
+11
+11
View File
@@ -166,3 +166,14 @@ func (c *clientCache) behaviorScoreLocked(state *clientState, paths []string) in
return 0
}
func (c *clientCache) pruneEventsLocked(state *clientState, now time.Time) {
cutoff := now.Add(-c.scoreWindow)
first := 0
for first < len(state.events) && !state.events[first].at.After(cutoff) {
first++
}
if first > 0 {
state.events = append([]scoreEvent(nil), state.events[first:]...)
}
}