[Tools for Devs] Blurt Nodes Checker

in blurt-101010 •  last year 

image


Hi devs on Blurt,

After the release 2 days ago of dBlurt, the typescript client library to connect to the Blurt blockchain (cf. my last post), it's now time for me to release an update of the blurt-nodes-checker typescript ESM library.

The library has been refactored to completely remove Axios which has been replaced by dBlurt for blockchain calls.

The library is also now Nexus compatible (communities on Blurt) but let's see it in detail


Blurt Nodes Checker

This is an Open Source library (for Browsers & NodeJS) that checks the status of the RPC nodes servers of the Blurt blockchain at a specified interval and send a report via an RxJS subscription. The result is stored in an array in memory and you can call it at any time.

The library also allows you to identify the compatibility of an RPC node with Nexus (communities on the Blurt blockchain) and to adapt the full test accordingly by including the Nexus methods.

This library is currently used by the BeBlurt application to identify the most responsive RPC Blurt nodes based on your internet connection. But also to identify Nexus-compatible RPC nodes as you can see below

image

image


Repositories

Blurt Nodes Checker is available on

gitlab: https://gitlab.com/beblurt/blurt-nodes-checker
npm: https://www.npmjs.com/package/@beblurt/blurt-nodes-checker


Initialisation

Initialise the Blurt nodes checker with params

/** Init the checker */
const nodesChecker = new BlurtNodesChecker(["url1", "url2", ...])

Params

  • url: array of node url to check
  • options (optional):
    • debug (boolean): if true show console info (default: false)
    • full (boolean): if false perform only a get_config with response time (default: false)
    • nexus (boolean): if true check if the rpc node is Nexus compatible (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)

if full = true (full checking) the methods below are checked:

  • condenser_api.get_config
  • condenser_api.get_accounts
  • 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

If it's a Nexus node the following methods are also checked:

  • bridge.account_notifications
  • bridge.get_payout_stats
  • bridge.get_post
  • bridge.get_profile
  • bridge.list_communities

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 => {
    ...
  }
})

Example usage


import { BlurtNodesChecker } from '@beblurt/blurt-nodes-checker'

/** Blurt nodes url to check */
const nodes = [
  "https://rpc.beblurt.com",
  "https://blurt-rpc.saboin.com",
  "https://rpc.blurt.world",
  "https://blurtrpc.actifit.io",
  "https://kentzz.blurt.world",
  "https://rpc.blurt.live",
  "https://blurtdev.techcoderx.com"
]

/** Options */
const options = {
  full: true,
  nexus: 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 BlurtNodesChecker(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()
  }
})  

Exemple of result for a full checking


[
  {
    url: "https://rpc.beblurt.com",
    nb_ok: 1,
    nb_error: 0,
    nb_degraded: 0,
    last_check: 1669607748639,
    status: "online",
    test_result: [
        {
            name: "Bridge | account_notifications ",
            description: "Account notifications",
            method: "bridge.account_notifications",
            success: true,
            duration: 314,
            last_check: 1669607748639
        },
        ...
        {
            name: "Condenser | Get Disccusion By Blog",
            description: "Retrieve a list of discussions by blog",
            method: "condenser_api.get_discussions_by_blog",
            success: true,
            duration: 1181,
            last_check: 1669607748639
        }
    ],
    version: "0.8.2",
    duration: 579,
    nexus: true,
    average_time: 1140,
  },
  ...
]

More details on the repositories


Last word

Feel free to test the library and give me feedback, for my part I tested it quickly under React and vanilla javascript and use it for BeBlurt (Angular & NodeJS).

As a reminder on the Blurt Discord there is a "dev" channel where I am very often and where you are welcome dear developers ;)


Witnesses

You are not a dev but still want to support the development on Blurt? It's easy and it doesn't cost you anything!

Just vote for my witness @nalexadre here:
https://blurtwallet.com/~witnesses?highlight=nalexadre
or here https://beblurt.com/@nalexadre/witness

And/or for one of the many other developers on Blurt with a Witness like those quoted in my previous post ;)

ps: A big thank you to all those who have already voted for my witness, thanks to you I made my return in the top 20.


Have fun
@nalexadre


Original background photo of this post by Kvistholt Photography on Unsplash

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  

Congratulations, your post has been curated by @dsc-r2cornell. You can use the tag #R2cornell. Also, find us on Discord

Manually curated by Blessed-girl

logo3 Discord.png

Felicitaciones, su publicación ha sido votada por @ dsc-r2cornell. Puedes usar el tag #R2cornell. También, nos puedes encontrar en Discord

Congratulations your post has been curated by @blurt-india


Posted from https://blurt.live