diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 99b5729cea250e4be0b73cf6972d6b6c88e54ced..0a4ee71d389a912601f6c949aa28b1cc962bb12e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,11 @@ Changelog ========= +0.21.1 +------ +* Fix non ascii text handling on some nodes +* Add STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF21 constant +* Fix get_curation_rewards + 0.21.0 ------ * First release for HF21 diff --git a/beem/comment.py b/beem/comment.py index ab737db47b6ff1b8d967e95446328d7dba651350..1300d5ab42f0f52ccb1d6da21a2bfad5bf7f28db 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -19,7 +19,7 @@ from .blockchainobject import BlockchainObject from .exceptions import ContentDoesNotExistsException, VotingInvalidOnArchivedPost from beembase import operations from beemgraphenebase.py23 import py23_bytes, bytes_types, integer_types, string_types, text_type -from beem.constants import STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6, STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF20, STEEM_100_PERCENT, STEEM_1_PERCENT +from beem.constants import STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6, STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF20, STEEM_100_PERCENT, STEEM_1_PERCENT, STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF21 log = logging.getLogger(__name__) @@ -320,7 +320,9 @@ class Comment(BlockchainObject): which will compentsate the curation penalty, if voting earlier than 15 minutes """ self.refresh() - if self.steem.hardfork >= 20: + if self.steem.hardfork >= 21: + reverse_auction_window_seconds = STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF21 + elif self.steem.hardfork >= 20: reverse_auction_window_seconds = STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF20 else: reverse_auction_window_seconds = STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6 @@ -361,7 +363,9 @@ class Comment(BlockchainObject): elapsed_seconds = (vote_time - self["created"]).total_seconds() else: raise ValueError("vote_time must be a string or a datetime") - if self.steem.hardfork >= 20: + if self.steem.hardfork >= 21: + reward = (elapsed_seconds / STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF21) + elif self.steem.hardfork >= 20: reward = (elapsed_seconds / STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF20) else: reward = (elapsed_seconds / STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6) @@ -509,13 +513,25 @@ class Comment(BlockchainObject): if median_hist is not None: median_price = Price(median_hist, steem_instance=self.steem) pending_rewards = False - total_vote_weight = self["total_vote_weight"] + if "active_votes" in self: + active_votes_list = self["active_votes"] + else: + active_votes_list = self.get_votes() + if "total_vote_weight" in self: + total_vote_weight = self["total_vote_weight"] + else: + total_vote_weight = 0 + for vote in active_votes_list: + total_vote_weight += vote["weight"] + if not self["allow_curation_rewards"] or not self.is_pending(): max_rewards = Amount(0, self.steem.steem_symbol, steem_instance=self.steem) unclaimed_rewards = max_rewards.copy() else: - if pending_payout_value is None: + if pending_payout_value is None and "pending_payout_value" in self: pending_payout_value = Amount(self["pending_payout_value"], steem_instance=self.steem) + elif pending_payout_value is None: + pending_payout_value = 0 elif isinstance(pending_payout_value, (float, integer_types)): pending_payout_value = Amount(pending_payout_value, self.steem.sbd_symbol, steem_instance=self.steem) elif isinstance(pending_payout_value, str): @@ -528,10 +544,7 @@ class Comment(BlockchainObject): pending_rewards = True active_votes = {} - if "active_votes" in self: - active_votes_list = self["active_votes"] - else: - active_votes_list = self.get_votes() + for vote in active_votes_list: if total_vote_weight > 0: claim = max_rewards * int(vote["weight"]) / total_vote_weight diff --git a/beem/constants.py b/beem/constants.py index 68cc841ef0e831daeb4ef71447b1f073352eaa30..070d03112a2602913b2ecbc7ca8066e1e91da25b 100644 --- a/beem/constants.py +++ b/beem/constants.py @@ -7,8 +7,15 @@ from __future__ import unicode_literals STEEM_100_PERCENT = 10000 STEEM_1_PERCENT = 100 +STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF21 = 300 STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF20 = 900 STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6 = 1800 + +STEEM_CONTENT_REWARD_PERCENT_HF16 = 7500 +STEEM_CONTENT_REWARD_PERCENT_HF21 = 6500 + +STEEM_DOWNVOTE_POOL_PERCENT_HF21 = 2500 + STEEM_VOTE_REGENERATION_SECONDS = 432000 STEEM_VOTING_MANA_REGENERATION_SECONDS = 432000 STEEM_VOTE_DUST_THRESHOLD = 50000000 diff --git a/beem/version.py b/beem/version.py index 4f660c520f44658ea81bac23d4dc04de8a22fbda..9c92f69296543abe5d1138c71b3a9ce78df859b2 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.21.0' +version = '0.21.1' diff --git a/beemapi/graphenerpc.py b/beemapi/graphenerpc.py index a82f36daf61985ba2379bc52afcc480ee6129a1d..e80c3d302d51cbbef3c46fac26c94bbfc0ebe33f 100644 --- a/beemapi/graphenerpc.py +++ b/beemapi/graphenerpc.py @@ -214,7 +214,7 @@ class GrapheneRPC(object): self.session = shared_session_instance() self.current_rpc = self.rpc_methods["jsonrpc"] self.headers = {'User-Agent': 'beem v%s' % (beem_version), - 'content-type': 'application/json'} + 'content-type': 'application/json; charset=utf-8'} try: if self.ws: self.ws.connect(self.url) @@ -282,7 +282,7 @@ class GrapheneRPC(object): timeout=self.timeout) if response.status_code == 401: raise UnauthorizedError - return response.text + return response def ws_send(self, payload): if self.ws is None: @@ -372,6 +372,7 @@ class GrapheneRPC(object): if self.url is None: raise RPCConnection("RPC is not connected!") reply = {} + response = None while True: self.nodes.increase_error_cnt_call() try: @@ -379,7 +380,8 @@ class GrapheneRPC(object): self.current_rpc == self.rpc_methods['wsappbase']: reply = self.ws_send(json.dumps(payload, ensure_ascii=False).encode('utf8')) else: - reply = self.request_send(json.dumps(payload, ensure_ascii=False).encode('utf8')) + response = self.request_send(json.dumps(payload, ensure_ascii=False).encode('utf8')) + reply = response.text if not bool(reply): try: self.nodes.sleep_and_check_retries("Empty Reply", call_retry=True) @@ -414,7 +416,10 @@ class GrapheneRPC(object): ret = {} try: - ret = json.loads(reply, strict=False, encoding="utf-8") + if response is None: + ret = json.loads(reply, strict=False, encoding="utf-8") + else: + ret = response.json() except ValueError: self._check_for_server_error(reply) diff --git a/beemapi/version.py b/beemapi/version.py index 4f660c520f44658ea81bac23d4dc04de8a22fbda..9c92f69296543abe5d1138c71b3a9ce78df859b2 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.21.0' +version = '0.21.1' diff --git a/beembase/version.py b/beembase/version.py index 4f660c520f44658ea81bac23d4dc04de8a22fbda..9c92f69296543abe5d1138c71b3a9ce78df859b2 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.21.0' +version = '0.21.1' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index 4f660c520f44658ea81bac23d4dc04de8a22fbda..9c92f69296543abe5d1138c71b3a9ce78df859b2 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.21.0' +version = '0.21.1' diff --git a/setup.py b/setup.py index b98cd309592105595b58324cc87c1eb90fb437cb..9230119d00134b29686be927c9c6f60b977f06a0 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.21.0' +VERSION = '0.21.1' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']