From 2c143dce0ff55feb35c7f6b9199479db88909903 Mon Sep 17 00:00:00 2001 From: Riobard Zhan Date: Thu, 10 Sep 2020 02:06:44 +0800 Subject: replay: minor API changes to more idiomatic Go Signed-off-by: Riobard Zhan Signed-off-by: Jason A. Donenfeld --- replay/replay.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'replay/replay.go') 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 } -- cgit v1.2.3-59-g8ed1b