Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: holgern/beem
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.20.21
Choose a base ref
...
head repository: holgern/beem
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.20.22
Choose a head ref

Commits on May 12, 2019

  1. improve permlink derivation

    * append timestamp also to root post permlinks to avoid overwriting exisiting
      posts with the same title (fixes #179)
    * avoid root permlinks to exceed the maximum length
    * refactoring reply permlinks
    crokkon committed May 12, 2019
    Copy the full SHA
    198d9a2 View commit details
  2. Copy the full SHA
    c6cb74f View commit details

Commits on Jun 30, 2019

  1. Create wls_post.py

    wls v2.5 reward / posting example
    alexpmorris authored Jun 30, 2019
    Copy the full SHA
    5fa27b0 View commit details
  2. Update operationids.py

    alexpmorris authored Jun 30, 2019
    Copy the full SHA
    acca00b View commit details
  3. Update objects.py

    alexpmorris authored Jun 30, 2019
    Copy the full SHA
    8e8fe0d View commit details
  4. Update operations.py

    alexpmorris authored Jun 30, 2019
    Copy the full SHA
    b9d91fb View commit details
  5. Update graphenerpc.py

    alexpmorris authored Jun 30, 2019
    Copy the full SHA
    9f0c222 View commit details

Commits on Jul 1, 2019

  1. Copy the full SHA
    884e151 View commit details
  2. Copy the full SHA
    143f113 View commit details
  3. Copy the full SHA
    d093248 View commit details
  4. Copy the full SHA
    5cbf489 View commit details
  5. Copy the full SHA
    c82d815 View commit details

Commits on Jul 10, 2019

  1. Merge pull request #181 from crokkon/permlink

    improve permlink derivation
    holgern authored Jul 10, 2019
    Copy the full SHA
    093c440 View commit details
  2. Merge pull request #192 from alexpmorris/wls-v25

    fixes compatibility issues with WhaleShares HF2 / v2.5
    holgern authored Jul 10, 2019
    Copy the full SHA
    6971c20 View commit details
  3. Merge pull request #194 from holgern/pyup-scheduled-update-2019-07-01

    Scheduled weekly dependency update for week 26
    holgern authored Jul 10, 2019
    Copy the full SHA
    9313349 View commit details
  4. Fix issue #195 and update nodelist

    * comment.downvote(100) will now downvote with 100 %
    holgern committed Jul 10, 2019
    Copy the full SHA
    1733efd View commit details
  5. Move vote function to steem and fix #193

    * 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
    holgern committed Jul 10, 2019
    Copy the full SHA
    be6461d View commit details
  6. Fix unit tests

    holgern committed Jul 10, 2019
    Copy the full SHA
    5af4870 View commit details
  7. Copy the full SHA
    a05d81f View commit details
  8. Copy the full SHA
    059778d View commit details

Commits on Jul 11, 2019

  1. Copy the full SHA
    f42b99a View commit details
  2. Fix unit test

    holgern committed Jul 11, 2019
    Copy the full SHA
    21dcdd4 View commit details
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Changelog
=========
0.20.22
-------
* Fix #195 - comment.downvote(100) will now downvote with 100%, negative numbers are not allowed anymore
* comment.upvote(), negative numbers are not allowed anymore
* Fix #193 - steem.vote() was added, so that voting is possible without tags_api
* PR #181 - improve permlink derivation by crokkon
* PR #192 - fixes compatibility issues with WhaleShares HF2 / v2.5 by alexpmorris
* Fix bug for get_estimated_block_num when a block is skipped

0.20.21
-------
* Fix float entered in Amount will be reduced by 0.001 due to rounding issues
18 changes: 18 additions & 0 deletions beem/blockchain.py
Original file line number Diff line number Diff line change
@@ -310,6 +310,16 @@ def get_estimated_block_num(self, date, estimateForwards=False, accurate=True):
.. note:: The block number returned depends on the ``mode`` used
when instantiating from this class.
.. code-block:: python
>>> from beem.blockchain import Blockchain
>>> from datetime import datetime
>>> blockchain = Blockchain()
>>> block_num = blockchain.get_estimated_block_num(datetime(2019, 6, 18, 5 ,8, 27))
>>> block_num == 33898184
True
"""
last_block = self.get_current_block()
date = addTzInfo(date)
@@ -328,9 +338,17 @@ def get_estimated_block_num(self, date, estimateForwards=False, accurate=True):
if block_number > last_block.identifier:
block_number = last_block.identifier
block_time_diff = timedelta(seconds=10)

last_block_time_diff_seconds = 10
second_last_block_time_diff_seconds = 10

while block_time_diff.total_seconds() > self.block_interval or block_time_diff.total_seconds() < -self.block_interval:
block = Block(block_number, steem_instance=self.steem)
second_last_block_time_diff_seconds = last_block_time_diff_seconds
last_block_time_diff_seconds = block_time_diff.total_seconds()
block_time_diff = date - block.time()
if second_last_block_time_diff_seconds == block_time_diff.total_seconds() and second_last_block_time_diff_seconds < 10:
return int(block_number)
delta = block_time_diff.total_seconds() // self.block_interval
if delta == 0 and block_time_diff.total_seconds() < 0:
delta = -1
48 changes: 19 additions & 29 deletions beem/cli.py
Original file line number Diff line number Diff line change
@@ -720,29 +720,25 @@ def listaccounts():

@cli.command()
@click.argument('post', nargs=1)
@click.argument('vote_weight', nargs=1, required=False)
@click.option('--weight', '-w', help='Vote weight (from 0.1 to 100.0)')
@click.option('--account', '-a', help='Voter account name')
def upvote(post, vote_weight, account, weight):
def upvote(post, account, weight):
"""Upvote a post/comment
POST is @author/permlink
"""
stm = shared_steem_instance()
if stm.rpc is not None:
stm.rpc.rpcconnect()
if not weight and vote_weight:
weight = vote_weight
if not weight.replace('.', '', 1).isdigit():
raise ValueError("vote_weight must be a float!")
else:
weight = float(weight)
if weight > 100:
raise ValueError("Maximum vote weight is 100.0!")
elif weight < -100:
raise ValueError("Minimum vote weight is -100.0!")
elif not weight and not vote_weight:
weight = stm.config["default_vote_weight"]
if not weight:
weight = stm.config["default_vote_weight"]
else:
weight = float(weight)
if weight > 100:
raise ValueError("Maximum vote weight is 100.0!")
elif weight < 0:
raise ValueError("Minimum vote weight is 0!")

if not account:
account = stm.config["default_account"]
if not unlock_wallet(stm):
@@ -761,29 +757,23 @@ def upvote(post, vote_weight, account, weight):

@cli.command()
@click.argument('post', nargs=1)
@click.argument('vote_weight', nargs=1, required=False)
@click.option('--account', '-a', help='Voter account name')
@click.option('--weight', '-w', default=100.0, help='Vote weight (from 0.1 to 100.0)')
def downvote(post, vote_weight, account, weight):
@click.option('--weight', '-w', default=100, help='Downvote weight (from 0.1 to 100.0)')
def downvote(post, account, weight):
"""Downvote a post/comment
POST is @author/permlink
"""
stm = shared_steem_instance()
if stm.rpc is not None:
stm.rpc.rpcconnect()
if not weight and vote_weight:
weight = vote_weight
if not weight.replace('.', '', 1).isdigit():
raise ValueError("vote_weight must be a float!")
else:
weight = float(weight)
if weight > 100:
raise ValueError("Maximum vote weight is 100.0!")
elif weight < -100:
raise ValueError("Minimum vote weight is -100.0!")
elif not weight and not vote_weight:
weight = stm.config["default_vote_weight"]

weight = float(weight)
if weight > 100:
raise ValueError("Maximum downvote weight is 100.0!")
elif weight < 0:
raise ValueError("Minimum downvote weight is 0!")

if not account:
account = stm.config["default_account"]
if not unlock_wallet(stm):
40 changes: 12 additions & 28 deletions beem/comment.py
Original file line number Diff line number Diff line change
@@ -145,7 +145,10 @@ def refresh(self):
[author, permlink] = resolve_authorperm(self.identifier)
self.steem.rpc.set_next_node_on_empty_reply(True)
if self.steem.rpc.get_use_appbase():
content = self.steem.rpc.get_discussion({'author': author, 'permlink': permlink}, api="tags")
try:
content = self.steem.rpc.get_discussion({'author': author, 'permlink': permlink}, api="tags")
except:
content = self.steem.rpc.get_content(author, permlink)
else:
content = self.steem.rpc.get_content(author, permlink)
if not content or not content['author'] or not content['permlink']:
@@ -596,25 +599,29 @@ def upvote(self, weight=+100, voter=None):
:param str voter: (optional) Voting account
"""
if weight < 0:
raise ValueError("Weight must be >= 0.")
last_payout = self.get('last_payout', None)
if last_payout is not None:
if formatToTimeStamp(last_payout) > 0:
raise VotingInvalidOnArchivedPost
return self.vote(weight, account=voter)

def downvote(self, weight=-100, voter=None):
def downvote(self, weight=100, voter=None):
""" Downvote the post
:param float weight: (optional) Weight for posting (-100.0 -
+100.0) defaults to -100.0
:param str voter: (optional) Voting account
"""
if weight < 0:
raise ValueError("Weight must be >= 0.")
last_payout = self.get('last_payout', None)
if last_payout is not None:
if formatToTimeStamp(last_payout) > 0:
raise VotingInvalidOnArchivedPost
return self.vote(weight, account=voter)
return self.vote(-weight, account=voter)

def vote(self, weight, account=None, identifier=None, **kwargs):
""" Vote for a post
@@ -627,33 +634,10 @@ def vote(self, weight, account=None, identifier=None, **kwargs):
form ``@author/permlink``.
"""
if not account:
if "default_account" in self.steem.config:
account = self.steem.config["default_account"]
if not account:
raise ValueError("You need to provide an account")
account = Account(account, steem_instance=self.steem)
if not identifier:
post_author = self["author"]
post_permlink = self["permlink"]
else:
[post_author, post_permlink] = resolve_authorperm(identifier)
identifier = construct_authorperm(self["author"], self["permlink"])

vote_weight = int(float(weight) * STEEM_1_PERCENT)
if vote_weight > STEEM_100_PERCENT:
vote_weight = STEEM_100_PERCENT
if vote_weight < -STEEM_100_PERCENT:
vote_weight = -STEEM_100_PERCENT

op = operations.Vote(
**{
"voter": account["name"],
"author": post_author,
"permlink": post_permlink,
"weight": vote_weight
})

return self.steem.finalizeOp(op, account, "posting", **kwargs)
return self.steem.vote(weight, identifier, account=account)

def edit(self, body, meta=None, replace=False):
""" Edit an existing post
35 changes: 21 additions & 14 deletions beem/nodelist.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ def __init__(self):
"version": "0.20.2",
"type": "appbase-limited",
"owner": "steemit",
"score": 100
"score": 50
},
{
"url": "https://steemd-appbase.steemit.com",
@@ -66,42 +66,42 @@ def __init__(self):
"version": "0.20.2",
"type": "appbase",
"owner": "gtg",
"score": 90
"score": 10
},
{
"url": "https://api.steemitdev.com",
"version": "0.19.11",
"type": "appbase-dev",
"owner": "steemit",
"score": 100
"score": 10
},
{
"url": "https://api.steemitstage.com",
"version": "0.19.11",
"type": "appbase-dev",
"owner": "steemit",
"score": 110
"score": 10
},
{
"url": "wss://rpc.steemviz.com",
"version": "0.19.12",
"type": "appbase",
"owner": "ausbitbank",
"score": 10
"score": -10
},
{
"url": "https://rpc.steemviz.com",
"version": "0.19.12",
"type": "appbase",
"owner": "ausbitbank",
"score": 100
"score": -10
},
{
"url": "wss://steemd.privex.io",
"version": "0.20.2",
"type": "appbase",
"owner": "privex",
"score": 50
"score": -10
},
{
"url": "https://steemd.privex.io",
@@ -129,14 +129,14 @@ def __init__(self):
"version": "0.19.12",
"type": "appbase",
"owner": "gtg",
"score": 75
"score": -10
},
{
"url": "https://gtg.steem.house:8090",
"version": "0.19.12",
"type": "appbase",
"owner": "gtg",
"score": 80
"score": -10
},
{
"url": "wss://steemd.pevo.science",
@@ -164,7 +164,7 @@ def __init__(self):
"version": "0.19.12",
"type": "appbase",
"owner": "netuoso",
"score": 20
"score": -10
},
{
"url": "wss://seed.bitcoiner.me",
@@ -206,7 +206,7 @@ def __init__(self):
"version": "0.19.12",
"type": "appbase",
"owner": "followbtcnews",
"score": 10
"score": 100
},
{
"url": "wss://anyx.io",
@@ -220,14 +220,21 @@ def __init__(self):
"version": "0.20.6",
"type": "appbase",
"owner": "anyx",
"score": 50
"score": 80
},
{
"url": "http://anyx.io",
"version": "0.20.6",
"type": "appbase",
"owner": "anyx",
"score": 50
},
{
"url": "https://rpc.curiesteem.com",
"version": "0.20.2",
"type": "appbase",
"owner": "curie",
"score": 50
"score": -10
},
{
"url": "wss://rpc.curiesteem.com",
@@ -241,7 +248,7 @@ def __init__(self):
"version": "0.20.8",
"type": "appbase",
"owner": "themarkymark",
"score": 50
"score": 90
},
{
"url": "wss://testnet.steem.vc",
40 changes: 38 additions & 2 deletions beem/steem.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
from .wallet import Wallet
from .steemconnect import SteemConnect
from .transactionbuilder import TransactionBuilder
from .utils import formatTime, resolve_authorperm, derive_permlink, remove_from_dict, addTzInfo, formatToTimeStamp
from .utils import formatTime, resolve_authorperm, derive_permlink, sanitize_permlink, remove_from_dict, addTzInfo, formatToTimeStamp
from beem.constants import STEEM_VOTE_REGENERATION_SECONDS, STEEM_100_PERCENT, STEEM_1_PERCENT, STEEM_RC_REGEN_TIME

log = logging.getLogger(__name__)
@@ -1775,7 +1775,7 @@ def get_hashtags(mdstring):
if not permlink:
permlink = derive_permlink(title, parent_permlink)
elif category:
parent_permlink = derive_permlink(category)
parent_permlink = sanitize_permlink(category)
parent_author = ""
if not permlink:
permlink = derive_permlink(title)
@@ -1817,6 +1817,42 @@ def get_hashtags(mdstring):

return self.finalizeOp(ops, account, "posting", **kwargs)

def vote(self, weight, identifier, account=None, **kwargs):
""" Vote for a post
:param float weight: Voting weight. Range: -100.0 - +100.0.
:param str identifier: Identifier for the post to vote. Takes the
form ``@author/permlink``.
:param str account: (optional) Account to use for voting. If
``account`` is not defined, the ``default_account`` will be used
or a ValueError will be raised
"""
if not account:
if "default_account" in self.config:
account = self.config["default_account"]
if not account:
raise ValueError("You need to provide an account")
account = Account(account, steem_instance=self)

[post_author, post_permlink] = resolve_authorperm(identifier)

vote_weight = int(float(weight) * STEEM_1_PERCENT)
if vote_weight > STEEM_100_PERCENT:
vote_weight = STEEM_100_PERCENT
if vote_weight < -STEEM_100_PERCENT:
vote_weight = -STEEM_100_PERCENT

op = operations.Vote(
**{
"voter": account["name"],
"author": post_author,
"permlink": post_permlink,
"weight": vote_weight
})

return self.finalizeOp(op, account, "posting", **kwargs)

def comment_options(self, options, identifier, beneficiaries=[],
account=None, **kwargs):
""" Set the comment options
Loading