hypercore-swarm-stream
Create a readable and/or writable stream of a hypercore feed on a hyperdrive-archive-swarm.
npm install hypercore-swarm-stream
Usage
var swarmStream = var signatures = var keys = signaturesvar publisher = var consumer = publisherconsumer
API
var stream = swarmStream([key], [options])
Same as hypercore-create-stream with an additional close
option, which closes the swarm when the stream ends.
key
is either a public or private key. If it is a public key, then the stream will be readable only. If it is a private key, then the stream will be both readable and writable. If it is undefined, then a new feed is created with public and private keys stream.key
and stream.secretKey
.
All options
are optional.
db: leveldb instance static: boolean storage: object tail: boolean start: integer end: integer close: boolean
stream.swarm
The hyperdrive swarm instance.
stream.close(callback)
Leave swarm.
stream.on('close')
Event emitted upon closing the swarm.
stream.on('connection', connection, info)
Emitted when you connect to another peer. Info is an object that contains info about the connection
type: 'tcp' // the type, tcp or utpinitiator: true // wheather we initiated the connection or someone else didchannel: // the channel this connetion was initiated on. only set if initiator === truehost: '127.0.0.1' // the remote address of the peer.port: 8080 // the remote port of the peer.id: // the remote peer's peer-id.