Namespace: Sync

Sync~Sync

The instance returned by module:Sync.

Source:

Members

events

Event emitter that emits Sync changes. See Events section for details.

Source:

peers

Set of currently connected peers for the log for this Sync instance.

Source:

Methods

add(entry)

Add a log entry to the Sync Protocol to be sent to peers.

Parameters:
Name Type Description
entry Entry

Log entry

Source:

start()

Start the Sync Protocol.

Source:

stop()

Stop the Sync Protocol.

Source:

Type Definitions

onSynced(peerId, heads)

Callback function when new heads have been received from other peers.

Parameters:
Name Type Description
peerId PeerID

PeerID of the peer who we received heads from

heads Array.<Entry>

An array of Log entries

Source:

Events

error

Event fired when an error occurs.

Parameters:
Name Type Description
error Error

The error that occured

Source:
Example
sync.events.on('error', (error) => ...)

join

Event fired when when a peer has connected and the exchange of heads has been completed.

Parameters:
Name Type Description
peerId PeerID

PeerID of the peer who we received heads from

heads Array.<Entry>

An array of Log entries

Source:
Example
sync.events.on('join', (peerID, heads) => ...)

leave

Event fired when a peer leaves the sync protocol.

Parameters:
Name Type Description
peerId PeerID

PeerID of the peer who left

Source:
Example
sync.events.on('leave', (peerID) => ...)