Sometimes, a small bug report can lead you down a deep rabbit hole. What starts as a "quick fix" spirals into a multi-day project. That's exactly what happened over the last couple of days, and I'm excited to share the results of a major refactor that will soon be proposed for the Hive-Engine distribution-engine-smt
.
It all started when I noticed that the rewards on the 1UP outpost weren't being reported correctly; they were just showing a zero balance.
My first step was to check the API call that the frontend uses. I tried it manually and was immediately greeted with a 500 Internal Server Error
. Well, that's definitely not good.
This sent me digging into the source code of the distribution-engine-smt
backend that Hive-Engine uses. What I found was... surprising. The code was still using the old beem
library for its blockchain interactions. Gasp! No wonder it wasn't working correctly.
My initial thought was that I'd just do a quick update, swap it over to hive-nectar
, and call it a day. But as I got deeper into the code, I realized that wasn't the only issue. Just like a lot of older codebases, it was using datetime
objects that were not timezone-aware, had a lot of linting errors, and was cluttered with unused imports.
So, I started cleaning it up. I fixed the code, updated the libraries, and then it came time to build the database to see if my changes worked. The initial sync process was taking far too long, streaming the main Hive chain and the Hive-Engine sidechain block by block.
To solve this, I added a batch mode to process the blocks in 1,000-block chunks. (You might remember me adding that bulk query feature to nectarengine
recently... now you know why!)
One thing led to another, and I ended up refactoring nearly the whole thing. The application now uses StreamHandlers
for processing the blockchain and is, I feel, much easier to read and maintain.
And the results speak for themselves. After the refactor, the API call now works perfectly.
Most importantly, with the API now feeding it the correct data, the 1UP outpost is displaying the rewards properly!
I have a tiny bit more work to do to button everything up, and then I'll be submitting an official pull request to the Hive-Engine team. Hopefully, they accept it so everyone can benefit from a more stable and reliable SMT API.
If you want to take a peek at it, have a gander at the GitHub Dev Branch.
As always,
Michael Garcia a.k.a. TheCrazyGM
You're a fricking badass, my friend! That's extraordinary! I can't imagine that the Hive Engine team wouldn't accept it, as it obviously improves the functionality of the code. 😁 🙏 💚 ✨ 🤙
Congratulations @thecrazygm! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP