Skip to main content
Module

x/earthstar/mod.ts>Peer

A specification and Javascript library for building online tools you can truly call your own.
Go to Latest
class Peer
implements IPeer
Re-export
import { Peer } from "https://deno.land/x/earthstar@v9.3.3/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
httpSyncer: Syncer<TransportHttpClient<SyncerBag>> | null
private
localSyncer: Syncer<TransportLocal<SyncerBag>> | null
private
targetLocalSyncers: Map<string, Syncer<TransportLocal<SyncerBag>>>
private
websocketSyncer: Syncer<TransportWebsocketClient<SyncerBag>> | null
peerId: PeerId

A subscribable map of the replicas stored in this peer.

syncerStatuses: SuperbusMap<string, Record<ShareAddress, SyncSessionStatus>>

A subscribable map of each of this Peer's sync operations' statuses

Methods

private
subscribeSyncerStatuses<TransportType extends ITransport<SyncerBag>>(syncer: Syncer<TransportType>)
addReplica(replica: IReplica): Promise<void>
getReplica(ws: ShareAddress): IReplica | undefined
hasShare(share: ShareAddress): boolean
removeReplica(replica: IReplica): Promise<void>
removeReplicaByShare(share: ShareAddress): Promise<void>
size(): number

Stop all synchronisations.

sync(target: IPeer | string)

Begin synchronising with a remote or local peer.

syncUntilCaughtUp(targets: (IPeer | string)[])

Sync with many peers until there is nothing left to pull, and then stops.