TRX1 Dev Blog #2 (February 2021)
First of all, February was a tough month for me and my family. We were planning a vacation that month. However, we all got sick one after another and we haven’t fully recovered yet. As a result, not much work was done. Nevertheless, the following projects received their updates.
aiothornode
This is a Python library for direct access to the THORNode REST API. Formerly that code was a part of the trader’s leaderboard and the monitoring bot and then I decided to extract the common parts, improve them and release them as a library. I hope it will be helpful to other devs too.
The current feature set consists of
- Connecting to a seed service (BNB Chaosnet and Multi-chain Testnet environments are supported for the moment)
- Filter out inactive nodes
- Simple consensus algorithm (connecting to a random subset of active nodes and sending them the same request and choosing the most frequent answer)
- Automatically updates the list of active nodes
The library uses asynchronous technics and requires aiohttp as a dependency for doing HTTP requests.
Code sample:
from aiothornode.connector import *
from aiothornode.types import *
import asyncio
import aiohttp
async def main():
env = CHAOS_NET_BNB_ENVIRONMENT
# env = TEST_NET_ENVIRONMENT_MULTI_1 # TestNet
# env = ThorEnvironment(seed_url='https://my-thor-seed.org') # custom
async with aiohttp.ClientSession() as session:
connector = ThorConnector(env, session)
constants = await connector.query_constants()
print(f'Constants: {constants}')
mimir = await connector.query_mimir()
mimir_1 = mimir['mimir//EMISSIONCURVE']
print(f'Mimir: {mimir}, EMISSIONCURVE = {mimir_1}')
queue = await connector.query_queue()
print(f'Queue: {queue}')
node_accounts = await connector.query_node_accounts()
print(f'Example node account: {node_accounts[0]}')
pool = await connector.query_pool('BNB.BNB', height=888123)
print(pool)
pools = await connector.query_pools()
print(pools[0])
print(f'Total {len(pools)} pools')
if __name__ == '__main__':
asyncio.run(main())
Source code repository: https://github.com/tirinox/aiothornode
Chaosnetleaders
This is a leaderboard of THORChain traders. In my view, the project requires major improvements. First, it must support the imminently approaching release of the multi-chain network. Second, I need to fix a couple of serious bugs that often cause it to go offline. And third, the UI should be more appealing.
In February, I started with rewriting the Midgard parser at the backend. Also, a parser for Midgard V2 was added along with a bunch of unit-tests in order to increase the robustness of the code. Additionally, the SQL model was reworked as well.
The project’s database once had been MySQL, but I switched to PostgreSQL as a modern solution.
Thus, all the changes were behind the scenes and are not reflected on the public website.
The source code is here: https://github.com/tirinox/chaosnetleaders/tree/multi (note the branch named “multi”).
Conclusion
That’s it for today.
My plan for March is to finish multi-chain support for the THORChain monitoring bot and Chaosnetleaders. And I am eager to present the first version of “Runiverse”, at least a dev preview with basic graphics.
Take care, THOR Warriors.