Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/earthstar/src/syncer/plum_tree.ts>PlumTree

Earthstar is a tool for private, undiscoverable, offline-first networks.
Go to Latest
class PlumTree
import { PlumTree } from "https://deno.land/x/earthstar@v10.0.0-alpha.4/src/syncer/plum_tree.ts";

A push-lazy-push-multicast tree, or 'PlumTree'. Organises a network of interconnected peers into a spanning tree where messaging resiliency, latency, and bandwidth are optimised.

When Earthstar sync agents finish their initial reconciliation phase they are switched to a mode where they are managed by a plumtree.

Properties

private
eagerMessageThumbnails: Set<string>

A list of previously received message IDs, used to check incoming messages for duplicates.

private
haveTimeouts: Map<DocThumbnail, number>

A map of DocThumbnails to timers.

private
messagingModes: Map<string, "EAGER" | "LAZY">

Methods

getMode(id: string): "EAGER" | "LAZY"
onEagerMessage(id: string, event: SyncAgentDocEvent): boolean

Triggered when the other peer sends a DOC message. Returns a boolean indicating whether to send a PRUNE event to the peer we got this message from.

onGraftMessage(id: string): void

Triggered when the other peer sends a graft, i.e. WANT message.

onLazyMessage(event: SyncAgentHaveEvent, dispatchGraft: (thumbnail: DocThumbnail) => void): void

Triggered when the other peer sends a HAVE message

onPrune(id: string): void

Triggered when the other peer sends a PRUNE message.