Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okdistribute/hyperhealth
Monitor the health of a hyperfeed (hypercore or hyperdrive), including peer count and peer mirror percentages.
https://github.com/okdistribute/hyperhealth
dat health hyperdrive monitoring network peer stats swarm
Last synced: 11 days ago
JSON representation
Monitor the health of a hyperfeed (hypercore or hyperdrive), including peer count and peer mirror percentages.
- Host: GitHub
- URL: https://github.com/okdistribute/hyperhealth
- Owner: okdistribute
- Created: 2016-12-21T01:27:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-12T20:23:02.000Z (over 5 years ago)
- Last Synced: 2024-04-14T12:10:30.163Z (7 months ago)
- Topics: dat, health, hyperdrive, monitoring, network, peer, stats, swarm
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 39
- Watchers: 6
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-peer-to-peer - hyperhealth
README
# 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
```js
var Health = require('hyperhealth')var health = Health(core)
// Will fire every 1 second
setInterval(function () {
var data = health.get()
console.log(data.peers.length, 'total peers')
console.log(data.length, 'total length')
console.log(data.byteLength, 'total bytes')
console.log('Peer 1 Downloaded ' + (data.peers[0].have / data.peers[0].length) * 100 + '%')
}, 1000)
```## API
### `health = Health(hypercore-or-hyperdrive, [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:
* ```byteLength```: Number of total bytes
* ```length```: Number of total blocks
* ```peers```: An array of the peers containing `id`, `length`, and `have`### Peer object
* `id`: The unique id of the peer, derived from `stream.remoteId`
* `have`: The number of blocks that have been downloaded by peer
* `length`: The total number of blocks