New version of Tower (Hivemind + REST)


Tower is a REST api service on the top Hivemind. It allows you to query a Hivemind database in terms of REST practices.

I have pushed a couple of updates and fixes to the Tower in the recent week.

Docker Installation Support

Tower may be a little bit tricky to configure/deploy if you don't have any experience with Python ecosystem.

In order to make the installation easier for parties interested, I have dockerized the app.

$ docker run -p 8090:8000 -e DB_PASS='hive' \
    -e DB_USER='hivemind_db_user' \
    -e DB_NAME='hivemind_db_name' \
    -e DB_PORT='5432' \
    -e DB_HOST='' \
    emrebeyler/tower:stable

will install and run the application on :8090.

This uses pre-built image on my Dockerhub profile. As an alternative, you can also build the image directly.

$ git clone https://github.com/emre/tower.git
$ cd tower
$ docker build -t tower .
$ docker run -p 8090:8000 -e DB_PASS='hive' \
    -e DB_USER='hivemind_db_user' \
    -e DB_NAME='hivemind_db_name' \
    -e DB_PORT='5432' \
    -e DB_HOST='' \
    tower

will do the same thing.

State API


Added a new /api/v1/state endpoint which represents the hive_state table in the database level.

It gives the latest processed block and dynamic global properties.

Relationship endpoints

4 new endpoints added to /api/v1/{username}/ namespace.

  • /api/v1/<username>/followers

Returns the follower list of <username.

  • /api/v1/<username>/following

Returns the following list of <username.

  • /api/v1/<username>/muting

Returns the muting list of <username.

  • /api/v1/<username>/muters

Returns the muter list of <username.

There is no pagination on any of these endpoints. Getting the list without pagination is not possible on RPC nodes, which makes the process slower in most cases.

In comparison, it's way more efficient to use Hivemind/Tower to get these lists.

Example:

Get the follower list of @utopian-io w/ steem-python:

$ time python -c 'from steem.account import Account;from steem import Steem;print(len(Account("utopian-io", steemd_instance=Steem(nodes=["https://rpc.usesteem.com"])).get_followers()));'

Result:

10937
python -c   0.54s user 0.32s system 6% cpu 13.952 total

Same script using Tower:

$ time python -c 'import requests; print(len(requests.get("http://tower.emrebeyler.me/api/v1/accounts/utopian-io/followers/").json()["followers"]))'

Result:

10936
python -c   0.36s user 0.31s system 29% cpu 2.264 total

6x more efficient, obviously.

By the way, there is a discrepancy on the follower count between Hivemind and RPC node. Investigating it.

Fix on /api/v1/accounts

There was a bug on account detail endpoint which was leading to 404 pages on account names including a . char on it. This issue is addressed w/ cfe43f.

Public tower nodes

Pull requests and commits

Vote for my witness

I do my best to support the blockchain with my skills. If you like what I do, consider casting a vote on via Steemconnect or on steemit.com

H2
H3
H4
3 columns
2 columns
1 column
18 Comments
Ecency