From 5198707bdbb04d12e98873efb42d9551a6082cc3 Mon Sep 17 00:00:00 2001 From: Holger Nahrstaedt Date: Wed, 14 Oct 2020 22:16:49 +0200 Subject: [PATCH] Fix feed_publish --- CHANGELOG.rst | 6 ++++++ beem/comment.py | 25 +++++++++++++++---------- beem/nodelist.py | 8 ++++++++ beem/version.py | 2 +- beem/witness.py | 4 ++-- beemapi/version.py | 2 +- beembase/version.py | 2 +- beemgraphenebase/version.py | 2 +- setup.py | 2 +- tests/beem/test_nodelist.py | 2 +- 10 files changed, 37 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9237b914..edf86730 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,11 @@ Changelog ========= +0.24.14 +------- +* Add new node (https://hive-api.arcange.eu) +* Fix logic in RankedPosts and AccountPosts +* Fix feed_publish + 0.24.12 ------- * Fix beempy witnessfeed for HF24 diff --git a/beem/comment.py b/beem/comment.py index 502d0396..a5c832cb 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -82,7 +82,7 @@ def __init__( def _parse_json_data(self, comment): parse_times = [ - "active", "cashout_time", "created", "last_payout", "last_update", + "active", "cashout_time", "created", "last_payout", "last_update", "updated", "max_cashout_time" ] for p in parse_times: @@ -197,7 +197,7 @@ def json(self): if "community" in output: output.pop("community") parse_times = [ - "active", "cashout_time", "created", "last_payout", "last_update", + "active", "cashout_time", "created", "last_payout", "last_update", "updated", "max_cashout_time" ] for p in parse_times: @@ -894,7 +894,7 @@ class RankedPosts(list): :param str start_permlink: start permlink :param Steem blockchain_instance: Steem() instance to use when accesing a RPC """ - def __init__(self, sort="trending", tag="", observer="", limit=21, start_author="", start_permlink="", lazy=False, full=True, raw_data=False, blockchain_instance=None, **kwargs): + def __init__(self, sort, tag="", observer="", limit=21, start_author="", start_permlink="", lazy=False, full=True, raw_data=False, blockchain_instance=None, **kwargs): if blockchain_instance is None: if kwargs.get("steem_instance"): blockchain_instance = kwargs["steem_instance"] @@ -910,11 +910,12 @@ def __init__(self, sort="trending", tag="", observer="", limit=21, start_author= last_n = -1 while len(comments) < limit and last_n != len(comments): last_n = len(comments) - self.blockchain.rpc.set_next_node_on_empty_reply(True) + self.blockchain.rpc.set_next_node_on_empty_reply(False) posts = self.blockchain.rpc.get_ranked_posts({"sort": sort, "tag": tag, "observer": observer, "limit": api_limit, "start_author": start_author, "start_permlink": start_permlink}, api="bridge") - + if posts is None: + continue for post in posts: if len(comments) > 0 and comments[-1]["author"] == post["author"] and comments[-1]["permlink"] == post["permlink"]: continue @@ -924,8 +925,9 @@ def __init__(self, sort="trending", tag="", observer="", limit=21, start_author= comments.append(post) else: comments.append(Comment(post, lazy=lazy, full=full, blockchain_instance=self.blockchain)) - start_author = comments[-1]["author"] - start_permlink = comments[-1]["permlink"] + if len(comments) > 0: + start_author = comments[-1]["author"] + start_permlink = comments[-1]["permlink"] if limit - len(comments) < 100: api_limit = limit - len(comments) + 1 super(RankedPosts, self).__init__(comments) @@ -958,10 +960,12 @@ def __init__(self, sort, account, observer="", limit=20, start_author="", start_ last_n = -1 while len(comments) < limit and last_n != len(comments): last_n = len(comments) - self.blockchain.rpc.set_next_node_on_empty_reply(True) + self.blockchain.rpc.set_next_node_on_empty_reply(False) posts = self.blockchain.rpc.get_account_posts({"sort": sort, "account": account, "observer": observer, "limit": api_limit, "start_author": start_author, "start_permlink": start_permlink}, api="bridge") + if posts is None: + continue for post in posts: if len(comments) > 0 and comments[-1]["author"] == post["author"] and comments[-1]["permlink"] == post["permlink"]: continue @@ -971,8 +975,9 @@ def __init__(self, sort, account, observer="", limit=20, start_author="", start_ comments.append(post) else: comments.append(Comment(post, lazy=lazy, full=full, blockchain_instance=self.blockchain)) - start_author = comments[-1]["author"] - start_permlink = comments[-1]["permlink"] + if len(comments) > 0: + start_author = comments[-1]["author"] + start_permlink = comments[-1]["permlink"] if limit - len(comments) < 100: api_limit = limit - len(comments) + 1 super(AccountPosts, self).__init__(comments) \ No newline at end of file diff --git a/beem/nodelist.py b/beem/nodelist.py index 6252dec9..b18caff7 100644 --- a/beem/nodelist.py +++ b/beem/nodelist.py @@ -189,6 +189,14 @@ def __init__(self): "owner": "deathwing", "hive": True, "score": 40 + }, + { + "url": "https://hive-api.arcange.eu", + "version": "1.24.2", + "type": "appbase", + "owner": "arcange", + "hive": True, + "score": 40 } ] super(NodeList, self).__init__(nodes) diff --git a/beem/version.py b/beem/version.py index b2417fa4..d4e86e35 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.12' +version = '0.24.13' diff --git a/beem/witness.py b/beem/witness.py index 402dec8d..209bd8bf 100644 --- a/beem/witness.py +++ b/beem/witness.py @@ -140,7 +140,7 @@ def feed_publish(self, elif isinstance(base, string_types): base = Amount(base, blockchain_instance=self.blockchain) else: - base = Amount(base, self.blockchain.sbd_symbol, blockchain_instance=self.blockchain) + base = Amount(base, self.blockchain.backed_token_symbol, blockchain_instance=self.blockchain) if isinstance(quote, Amount): quote = Amount(quote, blockchain_instance=self.blockchain) @@ -149,7 +149,7 @@ def feed_publish(self, else: quote = Amount(quote, self.blockchain.token_symbol, blockchain_instance=self.blockchain) - if not base.symbol == self.blockchain.sbd_symbol: + if not base.symbol == self.blockchain.backed_token_symbol: raise AssertionError() if not quote.symbol == self.blockchain.token_symbol: raise AssertionError() diff --git a/beemapi/version.py b/beemapi/version.py index b2417fa4..d4e86e35 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.12' +version = '0.24.13' diff --git a/beembase/version.py b/beembase/version.py index b2417fa4..d4e86e35 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.12' +version = '0.24.13' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index b2417fa4..d4e86e35 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.12' +version = '0.24.13' diff --git a/setup.py b/setup.py index 35dfbb31..73cd17f1 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.24.12' +VERSION = '0.24.13' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized'] diff --git a/tests/beem/test_nodelist.py b/tests/beem/test_nodelist.py index 9beac5bb..259851d4 100644 --- a/tests/beem/test_nodelist.py +++ b/tests/beem/test_nodelist.py @@ -20,7 +20,7 @@ def setUpClass(cls): def test_get_nodes(self): nodelist = NodeList() all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True, testnetdev=True) - self.assertEqual(len(nodelist) - 15, len(all_nodes)) + self.assertEqual(len(nodelist) - 16, len(all_nodes)) https_nodes = nodelist.get_nodes(wss=False) self.assertEqual(https_nodes[0][:5], 'https')