mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 10:04:01 +03:00
Add event stream module
This commit is contained in:
@@ -5,6 +5,7 @@ import "github.com/9seconds/mtg/v2/mtglib"
|
||||
type noop struct{}
|
||||
|
||||
func (n noop) SeenBefore(_ []byte) bool { return false }
|
||||
func (n noop) Shutdown() {}
|
||||
|
||||
func NewNoop() mtglib.AntiReplayCache {
|
||||
return noop{}
|
||||
|
||||
@@ -18,6 +18,8 @@ func (suite *NoopTestSuite) TestOp() {
|
||||
suite.False(filter.SeenBefore([]byte{4, 5, 6}))
|
||||
suite.False(filter.SeenBefore([]byte{1, 2, 3}))
|
||||
suite.False(filter.SeenBefore([]byte{4, 5, 6}))
|
||||
|
||||
filter.Shutdown()
|
||||
}
|
||||
|
||||
func TestNoop(t *testing.T) {
|
||||
|
||||
@@ -20,6 +20,8 @@ func (s *stableBloomFilter) SeenBefore(digest []byte) bool {
|
||||
return s.filter.TestAndAdd(digest)
|
||||
}
|
||||
|
||||
func (s *stableBloomFilter) Shutdown() {}
|
||||
|
||||
func NewStableBloomFilter(byteSize uint, errorRate float64) mtglib.AntiReplayCache {
|
||||
sf := boom.NewDefaultStableBloomFilter(byteSize*8, errorRate) // nolint: gomnd
|
||||
sf.SetHash(xxhash.New64())
|
||||
|
||||
@@ -18,6 +18,8 @@ func (suite *StableBloomFilterTestSuite) TestOp() {
|
||||
suite.False(filter.SeenBefore([]byte{4, 5, 6}))
|
||||
suite.True(filter.SeenBefore([]byte{1, 2, 3}))
|
||||
suite.True(filter.SeenBefore([]byte{4, 5, 6}))
|
||||
|
||||
filter.Shutdown()
|
||||
}
|
||||
|
||||
func TestStableBloomFilter(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user