Skip to content

Commit

Permalink
Fix feed_publish
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed Oct 14, 2020
1 parent d7dc41f commit 5198707
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 15 additions & 10 deletions beem/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
8 changes: 8 additions & 0 deletions beem/nodelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion beem/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.24.12'
version = '0.24.13'
4 changes: 2 additions & 2 deletions beem/witness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion beemapi/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.24.12'
version = '0.24.13'
2 changes: 1 addition & 1 deletion beembase/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.24.12'
version = '0.24.13'
2 changes: 1 addition & 1 deletion beemgraphenebase/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.24.12'
version = '0.24.13'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
2 changes: 1 addition & 1 deletion tests/beem/test_nodelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit 5198707

Please sign in to comment.