Skip to main content

Routing And Mesh

PrimaDB has a DAM-like routing layer, but not Gun’s exact wire format.

Routing Layer

Transport messages move through typed route envelopes with:

  • targeted peer routing
  • broadcast/topic-style delivery
  • presence
  • peer recommendation exchange
  • pull requests and responses
  • watch events
  • signaling payloads
  • batching and chunking
  • dedupe metadata such as content hashes and seen-by hints

Relay Mode

connectRelay(...) keeps the relay in the data path.

That means:

  • peer discovery still works
  • remote get/query/lex/snapshot still work
  • remote watches still work
  • but peer-to-peer traffic continues through the relay

Mesh Mode

connectMesh(...) uses the relay for discovery and signaling, then attempts direct peer links over WebRTC data channels.

That means:

  • same room plus relay-backed signaling is what triggers direct peering
  • sharing a relay alone does not automatically upgrade relay traffic into direct mesh traffic

This is close to how Gun behaves when its WebRTC plugin is active.

ICE Servers

PrimaDB does not hard-code STUN defaults in core. Mesh configs accept iceServers, and the example apps choose practical public defaults such as stun:stun.cloudflare.com:3478.