Skip to main content
Module

x/earthstar/mod.ts>Peer

Earthstar is a tool for private, undiscoverable, offline-first networks.
Go to Latest
class Peer
implements IPeer
import { Peer } from "https://deno.land/x/earthstar@v10.0.0-alpha.2/mod.ts";

Holds many shares' replicas and manages their synchronisation with other peers. Recommended as the point of contact between your application and Earthstar shares.

Constructors

new
Peer()

Properties

private
replicaEventBus: BlockingBus<Map<ShareAddress, Replica>>
replicaMap: Map<ShareAddress, Replica>

A subscribable map of the replicas stored in this peer.

Methods

addReplica(replica: Replica): Promise<void>
getReplica(ws: ShareAddress): Replica | undefined
hasShare(share: ShareAddress): boolean
onReplicasChange(callback: (map: Map<ShareAddress, Replica>) => void | Promise<void>)

Fires a given callback whenever the Peer's store of replicas changes.

removeReplica(replica: Replica): Promise<void>
removeReplicaByShare(share: ShareAddress): Promise<void>
size(): number

The number of replicas held by this peer

sync<F>(
target: IPeer | string,
live?,
formats?: FormatsArg<F>,
): Syncer<undefined, F>

Begin synchronising with a remote or local peer.