dedup

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PacketDeduplicator

type PacketDeduplicator struct {
	sync.Mutex // protects the seen map from concurrent access.
	// contains filtered or unexported fields
}

PacketDeduplicator is a structure that prevents processing of duplicate packets. It keeps a record of seen packets and the time they were last seen.

func NewDeduplicator

func NewDeduplicator(expiresAfter time.Duration) *PacketDeduplicator

NewDeduplicator creates a new PacketDeduplicator with a given hasher and expiration duration for packet records. It starts a background goroutine to periodically clean up expired packet records.

func (*PacketDeduplicator) Seen

func (p *PacketDeduplicator) Seen(sender, packetID uint32) bool

Seen checks whether a packet with the given sender and packetID has been seen before. If not, it records the packet as seen and returns false. Otherwise, it returns true.

func (*PacketDeduplicator) SeenData

func (p *PacketDeduplicator) SeenData(data []byte) bool

SeenData checks whether the data has been seen before based on its hashed value. If not, it records the data as seen and returns false. Otherwise, it returns true.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL