npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mintrawa/hive-nodes-checker

v0.0.7

Published

Regularly checks availability and performance of HIVE blockchain RPC nodes asynchronously

Downloads

3

Readme

HIVE nodes checker

Regularly checks availability and performance of HIVE blockchain RPC nodes asynchronously, stores the result in an in-memory array, and sends the result through a subscription (RxJS).

Getting Started

Installation

Using npm:

$  npm install @mintrawa/hive-nodes-checker --save

Using browser:

<script type="module" src="./dist/hive-nodes-checker.min.js"></script>

From the source:

clone the repository

$  git clone https://github.com/Mintrawa/hive-nodes-checker.git

Build for NodeJS/Angular... in "./lib" directory

$  npm run build

Build for browser (minified) in "./dist" directory

$  npm run build-browser

Initialisation

Initialise the HIVE nodes checker with params

/** Init the checker */
const nodesChecker = new HiveNodesChecker(["url"])

Params

  • url: array of node url to check
  • options (optional):
    • full (boolean): if false perform only a get_config with response time (default: false)
    • interval (seconds): delay in seconds between each execution (default: 900 seconds)
    • timeout (seconds): timeout in seconds for node request (default: 3 seconds)
    • reset (number): number max of test before resetting the counters (default: no reset)

Functions

start()

Start the checking process

/** Start the checker */
nodesChecker.start()

restart()

restart the checking process with the same params

/** Restart the checker */
nodesChecker.restart()

stop()

stop the checking process

/** Stop the checker */
nodesChecker.stop()

Message subscription

message.subscribe()

It use RxJS to send the result of a check

/** Subscribe results */
nodesChecker.message.subscribe({
  next: async m => {
    ...
  },
  error: error => {
    ...
  }
})

message.unsubscribe()

Unsubscribe manually from the Observable

/** Unsubscribe results */
nodesChecker.message.unsubscribe()
})

Example usage

Performing a full checking:

import { HiveNodesChecker } from '@mintrawa/hive-nodes-checker'

/** HIVE nodes url to check */
const nodes = [
  "https://api.hive.blog",
  "https://api.openhive.network",
  "https://api.deathwing.me",
  "https://rpc.ausbit.dev",
  "https://rpc.ecency.com",
  "https://hive-api.arcange.eu",
]

/** Options */
const options = {
  full: true,
  interval: 600, // 10 minutes
  reset: 144 // every 144 tests => 24 hours x 6 (10 minutes = 6 test per hours)
}
/** Init the checker */
const nodesChecker = new HiveNodesChecker(nodes, options)
/** Start the checker */
nodesChecker.start()
/** Subscribe results */
nodesChecker.message.subscribe({
  next: async m => {
    console.log('=====> NEW MESSAGE', m)
    console.log()
  },
  error: error => {
    console.log('=====> ERROR MESSAGE')
    console.log(error)
    console.log()

    /** Restart the checker */
    nodesChecker.restart()
  }
})  

Light checking

In this case, only a call to the rpc method condenser_api.get_config is made.

Result

[{
  "url":            string
  "nb_ok":          number
  "nb_error":       number
  "nb_degraded":    number
  "error"?:         string
  "last_check":     number
  "status":         "unkown"|"online"|"degraded"|"error"
  "duration"?:      number
  "average_time"?:  number
  "version"?:       string
  "deactivated"?:   boolean

  "test_result":    []
}]

Exemple of result for a light checking

[
  {
    "url": "https://api.hive.blog",
    "nb_ok": 1,
    "nb_error": 0,
    "nb_degraded": 0,
    "last_check": 1641001821365,
    "status": "online",
    "test_result": [],
    "version": "1.25.0",
    "duration": 1558
  },
  ...
]

Full checking

In this case the methods below are checked:

  • condenser_api.get_config

  • condenser_api.get_accounts

  • condenser_api.get_account_history

  • condenser_api.get_accounts_reputations

  • condenser_api.get_block

  • condenser_api.get_blog_entries

  • condenser_api.get_content

  • condenser_api.get_dynamic_global_properties

  • condenser_api.get_discussions_by_blog

  • bridge.get_post

  • bridge.get_account_posts

Result

[{
  "url":            string
  "nb_ok":          number
  "nb_error":       number
  "nb_degraded":    number
  "error"?:         string
  "last_check":     number
  "status":         "unkown"|"online"|"degraded"|"error"
  "duration"?:      number
  "average_time"?:  number
  "version"?:       string
  "deactivated"?:   boolean

  "test_result":   [{
    "name":        string
    "description": string
    "method":      string
    "success":     boolean
    "duration":    number
    "error"?:      string
    "last_check":  number
  }]
}]

Exemple of result for a full checking

[
  {
    "url": "https://api.hive.blog",
    "nb_ok": 1,
    "nb_error": 0,
    "last_check": 1641002823566,
    "status": "online",
    "test_result": [
      {
        "name": "Get Account",
        "description": "Retrieve an account details",
        "method": "condenser_api.get_accounts",
        "success": true,
        "duration": 1166,
        "last_check": 1641002823566
      },
      ...
    ],
    "version": "1.25.0",
    "duration": 1273,
    "average_time": 1748
  },
  ...
]

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

Copyright (C) 2021 @mintrawa (https://hive.blog/@mintrawa)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.