hyperhealth
Monitor the health of a hyperfeed (hypercore or hyperdrive), including peer count and peer mirror percentages.
Does not actually download any data content, only downloads some of the metadata and monitors the peer feeds.
npm install hyperhealth
Example
var Health = require('hyperhealth')
var health = Health(hypercore_feed)
// Will fire every 1 second
setInterval(function () {
var data = health.get()
console.log(data.peers.length, 'total peers')
console.log(data.bytes, 'total bytes')
console.log(data.byteLength, 'total length')
console.log('Peer 1 Downloaded ' + (data.peers[0].have / data.peers[0].length) * 100 + '%')
}, 1000)
API
health = Health(key-or-archive, [opts])
Takes a hyperdrive
or hypercore
instance. Returns an object health
.
health.get()
When called will return an object representing the health at a particular state.
Returns:
bytes
: Number of total bytesblocks
: Number of total blockspeers
: An array of the peers containingid
,blocks
, andhave
Peer object
id
: The unique id of the peer, derived fromstream.remoteId
have
: The number of blocks that have been downloadedblocks
: The total number of blocks