Giter Site home page Giter Site logo

okdistribute / hyperhealth Goto Github PK

View Code? Open in Web Editor NEW
39.0 6.0 6.0 23 KB

Monitor the health of a hyperfeed (hypercore or hyperdrive), including peer count and peer mirror percentages.

JavaScript 100.00%
dat peer hyperdrive health swarm monitoring network stats

hyperhealth's Introduction

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(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

hyperhealth's People

Contributors

joehand avatar karissa avatar okdistribute avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hyperhealth's Issues

some improvement suggestions

from @pvh

this a valid discovery key (for a hypercore)? -> need checksums to make sure the key is useful, documented example code showing how to handle invalid input. if bad, get a better key / fix typos / give up and move to Belize

is there anyone offering this data? who? -> it should be easy to review the peers you discover, what their network position is (local / DHT / and so on), as well as how much data they claim to have (perhaps the bitfield should be in the discovery traffic?) if not... what do you do? wait -- but how should that be communicated to the user?

am i able to connect to this data source? <----------- this is the most frustrating step to understand but critically the answer should ALWAYS be yes so i view this less as dat-project-level debugging infrastructure rather than user tools

  • for local mdns connections we should be able to answer this quickly and decisively
  • for dns-sd, it's harder! there are node-specific and peer-specific answers to this question. what's your NAT situation? (hint: it's always terrible, but maybe the peer is better?)
  • for dht traffic does this even work

if i CAN connect, how much data am i waiting for? how long is it going to take? with email, you don't see the email until it fully arrives. with the web things stream in. for many dat applications you might want different behaviours but it should be easy and documented how to track download speed / progress.

last we get into liveliness. what's my connectivity to DNS-SD? did a peer drop without sending me all the data i need and now i have an unfillable gap? is someone downloading from me right now so i should give them a moment for that to finish?

support hypercores

It'd be cool if this also supported hypercore as we could then plug it into our hyperops tools

No peers

I'm using dat 13.8.2 and just installed hyperhealth globally.

I've got 2-3 peers on the same archive, but hyperhealth shows 0 peers. Could it be because some dependencies are too old?

next version notes

  • connect to swarm and sparse download metadata

  • it shouldn't matter if i have the hypercore synced partially or not

  • if given the hyperdiscovery instance it could have more info

  • try to download a block

  • downloading the first block which is the type identifier

  • static method that checks the key

  • most of the others should have the hypercore instance

  • see if the dns-sd server is down

  • listen to 'warn' 'error' 'peer' from discovery-channel https://github.com/maxogden/discovery-channel/blob/master/index.js#L22-L24

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.