Use Peakd Beacon in your Python projects to find reliable nodes

avatar

Earlier today @peakd announced their new Node Beacon Project which allows you to find the best working nodes in real-time.

This is really handy for Peakd to allow you to automatically switch to an optimal node, especially right now when nodes are being replayed at the same time.

I thought this would be really handy for python scripts to be able to intelligently select nodes that are performance best at the current time. Beem, the python library I use, already has similar support but it isn't as up to date as Beacon.

I created and made public a simple wrapper for the Beacon api to allow you to use it easily in your scripts.

GitHub Repo

Using the library is really easy to use and understand. Feel free to submit a pull request if you think of any improvements. The code is licensed MIT and free to use anyway you like.

from best_hive_nodes import get_best_hive_nodes

print(get_best_hive_nodes())

Normally you wouldn't print the nodes but feed them into beem like this:

from beem import Hive
from best_hive_nodes import get_best_hive_nodes

nodes = get_best_hive_nodes()
hive= Hive(node=nodes)

The get_best_hive_nodes will query the @peakd Node Beacon api and return a list of the best nodes. You can optionally specify a score (typically 80-95) you want returned, if you don't it will use 90 as the default score. Unfortunately, there are not always nodes above 90 and it will return all nodes returned by the api (typically 80+ score) if it cannot find a single node meeting your score.

I recommend you visiting https://beacon.peakd.com/ to see how the nodes are tested and what the typical scores look like.

As of right now, all nodes are 89% or lower.

If it is unable to connect to the Beacon api, it will return a list of default nodes that are "usually" working.

As the nodes are currently in a constant state of flux, this library can help ease the difficulty of finding a working node. If you have script that is running 24/7, you can have it update your node list from time to time.



0
0
0.000
8 comments
avatar

I am still waiting for your reply. Why are you flagging my post?

0
0
0.000
avatar

You have much power so you will downvote to small users ?

0
0
0.000