Implement caching dns resolver

This commit is contained in:
9seconds
2021-03-30 14:14:37 +03:00
parent 841a4d2227
commit 10b78322a3
16 changed files with 163 additions and 47 deletions
-1
View File
@@ -5,7 +5,6 @@ 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{}
-2
View File
@@ -18,8 +18,6 @@ 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) {
-2
View File
@@ -20,8 +20,6 @@ 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())
-2
View File
@@ -18,8 +18,6 @@ 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) {