The instance returned by module:Sync.
Members
events
Event emitter that emits Sync changes. See Events section for details.
peers
Set of currently connected peers for the log for this Sync instance.
Methods
add(entry)
Add a log entry to the Sync Protocol to be sent to peers.
Parameters:
Name | Type | Description |
---|---|---|
entry |
Entry | Log entry |
start()
Start the Sync Protocol.
stop()
Stop the Sync Protocol.
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 |
Events
error
Event fired when an error occurs.
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | The error that occured |
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 |
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 |
Example
sync.events.on('leave', (peerID) => ...)