<p dir="auto">HafSQL runs on a HAF node and makes it possible to run certain queries on the HAF data. It does this by parsing the data already present in the HAF database and adding additional indexes and tables.
<p dir="auto">As I wrote in <a href="https://peakd.com/hive-139531/@mahdiyari/dhf-proposal-hive-related-development" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">the original proposal post, the first application is the HafSQL itself and the second is a way to provide this data to the apps and users.
<p dir="auto">It is fast and easy to setup on any HAF node and doesn't take that much space. Fast here doesn't mean 10 minutes. It can take around 10 hours to be ready on a HAF node which depends on the hardware. It is fast in regards that we are dealing with nearly 5 billion operations.
<p dir="auto">The first app is self explanatory but for the second one the original plan was to parse the SQL queries in a middleware and forward them into the database. What ended up being is a jussi compatible API endpoint that provides a JSON-RPC2 API access.
<p dir="auto">I did implement an structure to allow custom queries be implemented in the API as the community or the apps ask for them. For example one custom query that is already added is getting comments/posts sorted by their pending payout value.
<p dir="auto">I thought about this for a while and I think API is the better approach and will make it easier for public nodes to install and run. Some might decide to provide open access to the database and I will probably provide a public instance shortly too.
<hr />
<h3>Beta version
<p dir="auto">It is not really beta because it is ready but it might need some more testing in production and feedback before being fully released.
<p dir="auto">I encourage developers and anyone using hivesql to go through list of the available APIs and see if anything is missing in their opinion.
<p dir="auto">I expect to add some additional custom queries but I don't have a clear idea of what is being used.
<hr />
<h3>Going forward
<p dir="auto">The proposal has ended few days ago and I was doing the final touches since then. I expect to work on this project probably a few more days. Maybe not in terms of coding but testing in production, documenting, and adding custom queries that might come up.
<p dir="auto">The first motivation for starting this project was having an open source alternative to hivesql (which we have been paying $4,000 monthly through DHF). But a few times during the development I though about going a little bit further and replacing the hivemind too. HafSQL only misses a couple of things that is available on hivemind. I can try developing further but will need more feedback. I'm not sure yet how will public node providers go about this project.
<hr />
<h3>How HafSQL works
<p dir="auto">Examples:
<ul>
<li>Get all the transfer operations that have memo="test"
<pre><code>curl -s --data '{"jsonrpc":"2.0", "method":"hafsql.op_transfer", "params":{"memo": "test"}, "id":1}' https://rpc.mahdiyari.info
<ul>
<li>Get all the delegations to account "ocdb"
<pre><code>curl -s --data '{"jsonrpc":"2.0", "method":"hafsql.delegations", "params":{"delegatee": "ocdb"}, "id":1}' https://rpc.mahdiyari.info
<p dir="auto">Checkout the gitlab page of the <a href="https://gitlab.com/mahdiyari/hafsql-api" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">hafsql-api for the full list of APIs.
<hr />
<h3>Testing
<p dir="auto">You can try playing with the APIs or you can replay a <a href="https://gitlab.syncad.com/hive/haf" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">HAF node with the 5 million block_log and install HafSQL there. It should take maybe around 10-30 minutes. This can be helpful before running on a production HAF node as well.
<p dir="auto">Installation instructions are provided in the gitlab repository of each app. All the APIs are listed there as well as their parameters etc.
<p dir="auto"><br /><br /><span>HafSQL: <a href="https://gitlab.com/mahdiyari/hafsql" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://gitlab.com/mahdiyari/hafsql<span>
HafSQL-API: <a href="https://gitlab.com/mahdiyari/hafsql-api" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://gitlab.com/mahdiyari/hafsql-api<span>
RPC node: <a href="https://rpc.mahdiyari.info" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://rpc.mahdiyari.info
<hr />
<p dir="auto">Thanks for all the support. I appreciate it.
Good work 👍
Thanks for sharing and keep up the good work.
keep the good work up
The Hive.Pizza team manually curated this post.
$PIZZA slices delivered:
(2/5) @bigtakosensei tipped @mahdiyari
You can now send $PIZZA tips in Discord via tip.cc!
@tipu curate
Nice! 🙏🏾
!PIZZA
Congratulations @mahdiyari! Your post has been a top performer on the Hive blockchain and you have been rewarded with this rare badge
<table><tr><td><img src="https://images.hive.blog/60x60/http://hivebuzz.me/badges/toppayoutday.png" /><td>Post with the highest payout of the day. <p dir="auto"><sub><em>You can view your badges on <a href="https://hivebuzz.me/@mahdiyari" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">your board and compare yourself to others in the <a href="https://hivebuzz.me/ranking" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Ranking<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong>Check out our last posts: <table><tr><td><a href="/hive-122221/@hivebuzz/pud-202307"><img src="https://images.hive.blog/64x128/https://i.imgur.com/805FIIt.jpg" /><td><a href="/hive-122221/@hivebuzz/pud-202307">Hive Power Up Day - July 1st 2023<tr><td><a href="/hive-106258/@hivebuzz/hivefest-trf-2023"><img src="https://images.hive.blog/64x128/https://files.peakd.com/file/peakd-hive/hivebuzz/23wC7eJH6F57ZLKQHzTxzC23zx8AzVrmxWD6PyZtoHcCjQafpgtZyNrpVjoVY1cYLKmYH.png" /><td><a href="/hive-106258/@hivebuzz/hivefest-trf-2023">Announcing the Travel Reimbursement Fund for HiveFest⁸Keep the good work going bro!
You rock!
Wow this is very interesting! Will try this soon.
$WINE
Looking at software and mobile app development through the prism of complexity theory is an intriguing experience. Software development, like complexity theory, is characterized by a complex web of interdependencies, emergent features, and adaptability. This is particularly true when looking at the Go Wombat process.
awesome i will try it in a future, know i am learning more about sql queries :D