TwoTier

class TwoTier(core: Set<PeerId>, attachment: (PeerId) -> PeerId?) : TopologyPolicy

The federated two-tier shape: a small core of servers fully meshed among themselves, each fronting a periphery of clients that attach to exactly one of them. Unlike FullFanout/RandomKRegular, this policy is anisotropic — the view a node gets depends on where it sits, not just how many peers there are:

  • A server (self ∈ core) floods the other servers plus its own local clients(core - self) ∪ { client : attachment(client) == self } — so a broadcast crosses the core once and each server fans it out to its own periphery. No server ever floods another server's clients.

  • A client (self ∉ core) floods only the one server it attaches to (attachment(self)); that server is its sole relay into the rest of the graph.

The union of every node's active view covers the whole roster, so a broadcast originating anywhere reaches everyone — via at most one core hop.

attachment maps a client to the server it attaches to, or null when the client is unattached/unknown. A null (or off-roster) server yields an empty view: the client can't flood until it (re)attaches — the failover seam is handled by the bootstrap layer, not here. Every result is intersected with roster so only live peers are targeted, and never contains self.

All selection is deterministicTwoTier owns no randomness; it is a pure function of (self, roster, core, attachment). One instance per node.

Constructors

Link copied to clipboard
constructor(core: Set<PeerId>, attachment: (PeerId) -> PeerId?)

Functions

Link copied to clipboard
open override fun activeView(self: PeerId, roster: Set<PeerId>): Set<PeerId>

The peers this node eager-floods to and GCs against, selected from roster (which includes self; the result never does). Called on every roster or liveness change with the currently-live members.

Link copied to clipboard
open override fun antiEntropyPool(self: PeerId, roster: Set<PeerId>): Set<PeerId>

The pool this node samples anti-entropy partners from — usually every other member (roster minus self); structural topologies may restrict it (e.g. tier-local). Never contains self.