PeerRoster

class PeerRoster(replicaId: ReplicaId)

An add-wins peer presence roster backed by ORSet.

Multicast discovery is lossy and reorders packets — an ORSet is the natural shape for a presence set where concurrent announce + goodbye resolves in favour of the add (a goodbye only cancels the specific dots it has witnessed).

Usage

Wire mDNS announce and goodbye observations to announce and goodbye. Read peers for a reactive view of the current peer set.

For multi-replica convergence (e.g. two discovery nodes), call merge with the remote replica's roster snapshot.

Parameters

replicaId

The stable identity of this node's replica — must be unique across all nodes that will eventually merge with each other.

Constructors

Link copied to clipboard
constructor(replicaId: ReplicaId)

Properties

Link copied to clipboard
val peers: StateFlow<Set<PeerId>>

Live view of currently announced peers.

Functions

Link copied to clipboard
fun announce(peerId: PeerId)

Records an announce event: peerId is now visible on the network.

Link copied to clipboard
fun goodbye(peerId: PeerId)

Records a goodbye event: peerId has left the network.

Link copied to clipboard
fun merge(other: PeerRoster)

Merges other's roster into this one.