feat(botfilter): add clientCache.pruneEventsLocked
This commit is contained in:
1 parent
a1332aac20
commit
f9bc58409a
1 file changed
+11
@@ -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:]...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user