p2p/protocol/identify/observed_addr_manager library

Observed address manager for libp2p.

This file contains the implementation of the observed address manager, which tracks addresses that peers have observed for us.

This is a port of the Go implementation from go-libp2p/p2p/protocol/identify/obsaddr.go to Dart, using native Dart idioms.

Classes

ConnAdapter
Adapter to make Conn implement ConnMultiaddrs
ConnMultiaddrs
connMultiaddrs provides isClosed along with network.ConnMultiaddrs. It is easier to mock this than network.Conn
Observation
ObservedAddrManager
ObservedAddrManager maps connection's local multiaddrs to their externally observable multiaddress
ObserverSet
observerSet is the set of observers who have observed ThinWaistAddr
ThinWaist
thinWaist is a class that stores the address along with it's thin waist prefix and rest of the multiaddr
ThinWaistWithCount
thinWaistWithCount is a thinWaist along with the count of the connection that have it as the local address

Constants

activationThresh → const int
ActivationThresh sets how many times an address must be seen as "activated" and therefore advertised to other peers as an address that the local peer can be contacted on. The "seen" events expire by default after 40 minutes (OwnObservedAddressTTL * ActivationThreshold). The are cleaned up during the GC rounds set by GCInterval.
maxExternalThinWaistAddrsPerLocalAddr → const int
observedAddrManagerWorkerChannelSize → const int
observedAddrManagerWorkerChannelSize defines how many addresses can be enqueued for adding to an ObservedAddrManager.
observerSetCacheSize → const int
observerSetCacheSize is the number of transport sharing the same thinwaist (tcp, ws, wss), (quic, webtransport, webrtc-direct) This is 3 in practice right now, but keep a buffer of 3 extra elements

Functions

getObserver(MultiAddr ma) String?
getObserver returns the observer for the multiaddress For an IPv4 multiaddress the observer is the IP address For an IPv6 multiaddress the observer is the first /56 prefix of the IP address
thinWaistForm(MultiAddr a) ThinWaist?
Creates a thin waist form of a multiaddress.