|
|
@@ -1,6 +1,8 @@
|
|
1
|
1
|
package antireplay
|
|
2
|
2
|
|
|
3
|
3
|
import (
|
|
|
4
|
+ "sync"
|
|
|
5
|
+
|
|
4
|
6
|
"github.com/9seconds/mtg/v2/mtglib"
|
|
5
|
7
|
"github.com/OneOfOne/xxhash"
|
|
6
|
8
|
boom "github.com/tylertreat/BoomFilters"
|
|
|
@@ -8,9 +10,13 @@ import (
|
|
8
|
10
|
|
|
9
|
11
|
type stableBloomFilter struct {
|
|
10
|
12
|
filter boom.StableBloomFilter
|
|
|
13
|
+ mutex sync.Mutex
|
|
11
|
14
|
}
|
|
12
|
15
|
|
|
13
|
16
|
func (s *stableBloomFilter) SeenBefore(digest []byte) bool {
|
|
|
17
|
+ s.mutex.Lock()
|
|
|
18
|
+ defer s.mutex.Unlock()
|
|
|
19
|
+
|
|
14
|
20
|
return s.filter.TestAndAdd(digest)
|
|
15
|
21
|
}
|
|
16
|
22
|
|