Lightsteem 0.0.4 - Broadcasting support
Lightsteem is a lightweight python client for STEEM blockchain. I have been working on a couple of things after the initial release and here is the new version.
Installation / Updating
If you don't have lightsteem yet:
$ pip install lighsteem
if you have it already:
$ pip install lightsteem --upgrade
Broadcasting Support and Transaction signing
You can now push transactions to the blockchain.
Example: Broadcasting a witness vote
from lightsteem.client import Client
from lightsteem.datastructures import Operation
c = Client(
keys=["<active_private_key>",])
op = Operation('account_witness_vote', {
'account': '<your_account>',
'witness': 'emrebeyler',
'approve': True,
})
c.broadcast(op)
The Operation tuple is a simple named tuple where the first parameter is the operation name, and the second parameter is the operation value on STEEM blockchain specs.
Example: Creating a Transfer
from lightsteem.client import Client
from lightsteem.broadcast.transaction_builder import TransactionBuilder
from lightsteem.datastructures import Operation
import logging
c = Client(
keys=["<active_key>",])
op = Operation('transfer', {
'from': 'emrebeyler',
'to': 'utopian-io',
'amount': '0.001 SBD',
'memo': 'test1!'
})
c.broadcast(ops)
For the reference, transaction signing stuff is derived from steem-python with little changes. Serializers are not ported, instead, I have used get_transaction_hex
call in steemd.
Broadcasting multiple operations
Just sending an iterable to the client.broadcast
is enough.
Example: Creating multiple transfers in one transaction
from lightsteem.client import Client
from lightsteem.datastructures import Operation
c = Client(
keys=["<active_key>",])
ops = [
Operation('transfer', {
'from': 'emrebeyler',
'to': 'utopian-io',
'amount': '0.001 SBD',
'memo': 'test1!'
}),
Operation('transfer', {
'from': 'emrebeyler',
'to': 'steemhunt',
'amount': '0.001 SBD',
'memo': 'test2!'
}),
]
c.broadcast(ops)
Retry and Failover changes on RPC calls
First implementation on retry/failover was lacking timeout handling and had a linear retry logic.
With this version, if a node returns an HTTP status between *400 and 600 or had a timeout, client retries up to 5 times the same node with an exponential backoff algorithm.
If there is no success, switches to the next available node.
Unit tests and Continuous Integration
Added initial unit tests and setup TravisCI. Now, every commit, pull request will have a custom build checks for the unit tests results.
Code coverage is not the best at the moment, but it will be better.
Changeset
Lots of small things are also changed.
All changes can be seen in this compare page.
Roadmap
With the transaction signing, I want to focus on unit tests. One big missing thing is also documentation and tutorials for people to use Lightsteem.
Contributing
I have a separate Discord server for Lightsteem. If you have any ideas, or if you want to add a new feature, let's collaborate here. :)
Notice
This library is under development and may include bugs. If you plan to use it on production, please do your own audit beforehand.
Thank you for your contribution. Looks great and for sure documentation is one thing which people would like to go through before diving deep into the project.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @codingdefined!
So far this week you've reviewed 6 contributions. Keep up the good work!
Hey @emrebeyler
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!