diff options
author | Riobard Zhan <me@riobard.com> | 2020-09-10 02:06:44 +0800 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-10-14 10:46:00 +0200 |
commit | 2c143dce0ff55feb35c7f6b9199479db88909903 (patch) | |
tree | bb22f8ee6531aaedb338caf56f404ad0d96c96e2 /replay/replay.go | |
parent | 22af3890f60d11472977f2fbdf50e6d5b406e356 (diff) |
replay: minor API changes to more idiomatic Go
Signed-off-by: Riobard Zhan <me@riobard.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'replay/replay.go')
-rw-r--r-- | replay/replay.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/replay/replay.go b/replay/replay.go index 8685712..5b2de41 100644 --- a/replay/replay.go +++ b/replay/replay.go @@ -17,24 +17,24 @@ const ( bitMask = blockBits - 1 ) -// A ReplayFilter rejects replayed messages by checking if message counter value is +// A Filter rejects replayed messages by checking if message counter value is // within a sliding window of previously received messages. -// The zero value for ReplayFilter is an empty filter ready to use. +// The zero value for Filter is an empty filter ready to use. // Filters are unsafe for concurrent use. -type ReplayFilter struct { +type Filter struct { last uint64 ring [ringBlocks]block } -// Init resets the filter to empty state. -func (f *ReplayFilter) Init() { +// Reset resets the filter to empty state. +func (f *Filter) Reset() { f.last = 0 f.ring[0] = 0 } // ValidateCounter checks if the counter should be accepted. // Overlimit counters (>= limit) are always rejected. -func (f *ReplayFilter) ValidateCounter(counter uint64, limit uint64) bool { +func (f *Filter) ValidateCounter(counter uint64, limit uint64) bool { if counter >= limit { return false } |