new Peer(id, txopt)
Abstract representation of a peer. Accepts any objectMode=true Duplex stream and a unique ID. Messages sent to peer will be written to the stream. module:brig/consensus~Cluster expects messages from peers to be read from this stream.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id | string | Peer ID. | |
tx | module:brig/consensus~peerTxHandler | <optional> | User-defined transport. |
- Source
Extends
- EventEmitter
Methods
send(message) → {module:brig/consensus~Peer}
Writes the message to the underlying stream.
Parameters:
Name | Type | Description |
---|---|---|
message | module:brig/messages~Message | The message to send. |
- Source
Fires:
- module:brig/events~event:MessageQueued
Returns: