Hey everyone,
They say "Necessity is the mother of invention", and today's post is an update to my nectarengine
library that proves the point. I'm working on a project that requires fetching large amounts of block data from the Hive-Engine sidechain, and doing it one block at a time is incredibly inefficient. So, I've added a new, more powerful method to handle this.
I'm happy to announce that nectarengine
version 0.1.1 is now live!
The main feature of this release is the new getBlockRangeInfo
method. This function is a convenience wrapper around the getBlockRangeInfo
JSON-RPC call allowing you to get information for a consecutive range of blocks in a single request.
While you could always get block info by calling get_block_info
repeatedly, this new method is much more efficient. It can fetch up to 1000 blocks in one go which drastically reduces the number of API calls and the time needed to gather large amounts of data.
The function is simple to use. You provide a start_block
number and the count
of blocks you want to retrieve. It then returns a list of block data dictionaries. Here's a look at the function signature:
def get_block_range_info(self, start_block: int, count: int) -> List[Dict[str, Any]]:
There's a reason this is a special addition. The getBlockRangeInfo
call is very resource-intensive, and as a result, it's disabled on almost every public Hive-Engine node. Because I needed it for a project I'm working on, I had to add it to the library to use against my own private node where I know it's enabled. So, while this feature is powerful, it's one you'll likely only be able to use if you're running your own node.
I've included a demo script in the library's examples to show how it works. This update is a great example of how personal project needs can lead to improvements that benefit the wider ecosystem, even if the features are a bit niche.
As always,
Michael Garcia a.k.a. TheCrazyGM
I appreciate your work on this, I know we are deeper than we ever expected to be able to see these payouts, but I think the juice is worth the squeeze in the end.
!PAKX
!PIMP
!PIZZA
View or trade
PAKX
tokens.Use !PAKX command if you hold enough balance to call for a @pakx vote on worthy posts! More details available on PAKX Blog.
$PIZZA slices delivered:
@ecoinstant(2/20) tipped @thecrazygm
Come get MOONed!