Skip to content

Commit

Permalink
blockchain.get_all_accounts(): suppress duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
crokkon committed Jun 15, 2018
1 parent 58f4585 commit d318edf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions beem/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ def get_all_accounts(self, start='', stop='', steps=1e3, limit=-1, **kwargs):
:param int steps: Obtain ``steps`` ret with a single call from RPC
"""
lastname = start
skipname = ''
cnt = 1
if not self.steem.is_connected():
raise OfflineHasNoRPCException("No RPC available in offline mode!")
Expand All @@ -591,10 +592,15 @@ def get_all_accounts(self, start='', stop='', steps=1e3, limit=-1, **kwargs):
else:
ret = self.steem.rpc.lookup_accounts(lastname, steps)
for account in ret:
# skip the first result of this call if it's identical to the
# last result of the previous call
if account == skipname:
continue
yield account
cnt += 1
if account == stop or (limit > 0 and cnt > limit):
raise StopIteration
skipname = ret[-1]
if lastname == ret[-1]:
raise StopIteration
lastname = ret[-1]
Expand Down

0 comments on commit d318edf

Please sign in to comment.