Class SeenPackets
A memory of recently seen packets, so a node relays each one only once.
public sealed class SeenPackets : IDisposable
- Inheritance
-
SeenPackets
- Implements
- Inherited Members
Remarks
Without one, a flood multiplies without bound. The core cache is generic over its size, which cannot cross the C ABI, so this one is sized when it is built.
Constructors
SeenPackets(int)
Creates an empty cache.
public SeenPackets(int capacity = 64)
Parameters
capacityintHow many recently seen packets to remember. A capacity of 0 remembers nothing, so every copy of a packet is relayed.
Exceptions
- PamojaException
The native cache could not be created.
Properties
Capacity
How many packets this cache remembers.
public int Capacity { get; }
Property Value
Methods
Contains(uint, ushort)
Reports whether a packet is remembered, without recording it.
public bool Contains(uint src, ushort id)
Parameters
Returns
- bool
Whether the packet has been seen recently.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Record(uint, ushort)
Records a packet and reports whether it was new.
public bool Record(uint src, ushort id)
Parameters
Returns
- bool
truewhen the packet had not been seen, which is when a node should act on it and relay it, andfalsefor a duplicate.