update for beem - new vote function in Steem(), upvote/downvote fixed, permlink generation improved and whaleshares support fixed

in utopian-io •  3 months ago 

Repository

https://github.com/holgern/beem


beem-logo\n

beem is a python library for steem. beem has now 495 unit tests and a coverage of 70 %. The current version is 0.20.22.
I created a discord channel for answering a question or discussing beem: https://discord.gg/4HM592V
The newest beem version can be installed by:

pip install -U beem

or when using conda:

conda install beem

beem can be updated by:

conda update beem

Bug fixes

get_estimated_block_num() returns results, when a block is missing

from beem.blockchain import Blockchain
from beem.block import Block
from datetime import datetime
print(Block(33898183)["timestamp"])
print(Block(33898184)["timestamp"])

returns

datetime.datetime(2019, 6, 18, 5, 8, 24, tzinfo=<UTC>)
datetime.datetime(2019, 6, 18, 5, 8, 33, tzinfo=<UTC>)

The time difference between block 33898184 and 33898183 is 9 seconds, which leads for timestamps between them to an infinite loop in get_estimated_block_num

This is fixed by checking of the second_last_block_time_diff_seconds == block_time_diff.total_seconds() in the while loop and returning the current block_num when true. This prevents infinite loops in which block_num jumps bewteen two values.

blockchain = Blockchain()
block_num = blockchain.get_estimated_block_num(datetime(2019, 6, 18, 5 ,8, 27))
print(block_num)

returns now

33898184

New Features

Move the vote function to the Steem class

It is now possible to vote with the Steem class:

from beem import Steem
stm = Steem(keys=["xxx"])
stm.vote(100, "@author/permlink", account="voter1")

This allows it to vote without loading the content with Comment. A wrapper function was added to Comment, so that is still possible to use

from beem.comment import Comment
c = Comment("@author/permlink")
c.vote(100, account="voter1")

Upvote and Downvote accepts only positive weights now

Usage: beempy upvote [OPTIONS] POST

  Upvote a post/comment

  POST is @author/permlink

Options:
  -w, --weight TEXT   Vote weight (from 0.1 to 100.0)
  -a, --account TEXT  Voter account name
  --help              Show this message and exit.

and

Usage: beempy downvote [OPTIONS] POST

  Downvote a post/comment

  POST is @author/permlink

Options:
  -a, --account TEXT    Voter account name
  -w, --weight INTEGER  Downvote weight (from 0.1 to 100.0)
  --help                Show this message and exit.

So downvote accepts only positive numbers now. So it is not possible anymore to downvote with upvote() and to upvote with downvote().

Update nodelist

The list of working node was update in Nodelist

from beem.nodelist import NodeList
nodes = NodeList()
nodes.get_nodes()

returns now

['https://steemd.minnowsupportproject.org',
 'https://rpc.usesteem.com',
 'https://anyx.io',
 'https://steemd.privex.io',
 'http://anyx.io',
 'https://appbasetest.timcliff.com',
 'https://api.steem.house']

Accepted PR

improve permlink derivation #181 by crokkon

PR #181

  • append timestamp also to root post permlinks to avoid overwriting existing
    posts with the same title (fixes #179)
  • avoid root permlinks to exceed the maximum length
  • refactoring reply permlinks

fixes compatibility issues with WhaleShares HF2 / v2.5 #192 by alexpmorris

PR #192

Commits

Fix float parsing for beempy upvote and downvote

Fix unit tests for changed upvote and downvote in beempy

* Fix bug for get_estimated_block_num when a block is missing

Move vote function to steem and fix #193

  • commit be6461d
  • The vote operation is now available at the steem object
  • A vote wrapper function with the old syntax is available at comment
  • The upvote and downvote at the cli (beempy) has now one argument, the weight must specified by --weight or -w

Fix issue #195 and update nodelist

Github account

https://github.com/holgern

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Interesting find with the 9 seconds interval between consecutive blocks. This changeset generally includes minor updates, but good to see Beem is maintained well.


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? Chat with us on Discord.

[utopian-moderator]

Thanks for the review.
I'm planing a major update when the next hardfork is there :).

Thank you for your review, @emrebeyler! Keep up the good work!

dieses update möchte @backinblackdevil bestimmt gleich installieren ;-)

Do you have any code for a beem bid bot


Congratulations @holger80!
You raised your level and are now an Orca!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!