Beem 0.20.17: Blockchain.stream()/Block() fail with only_ops=True on blocks without ops

in #utopian-io5 years ago

Project Information

A GitHub issue was created and a PR with a fix was merged by the PO.

Expected behavior

blockchain.stream(start, stop, only_ops=True) should return all operations, including virtual ops, contained in the block range from start to stop. The same should be possible via Block(blocknum, only_ops=True) for individual blocks. If a block does not contain operations, the calls should return an empty list. While this situation is rare for current blocks, it is present frequently on early Steem blocks, testnets and Steem forks.

Actual behavior

blockchain.stream(start, stop, only_ops=True) and Block(blocknum, only_ops=True) fail with a BlockDoesNotExistsException if the block contains no operations.

How to reproduce

from beem.blockchain import Blockchain
b = Blockchain()
for op in b.stream(start=1000, stop=1001, only_ops=True):
    print(op)

or

from beem.block import Block
b = Block(1000, only_ops=True)

Output:

Traceback (most recent call last):
  File "bug_get_ops_in_block.py", line 8, in <module>
    b = Block(1000, only_ops=True)
  File "/usr/local/lib/python3.6/site-packages/beem/block.py", line 76, in __init__
    steem_instance=steem_instance
  File "/usr/local/lib/python3.6/site-packages/beem/blockchainobject.py", line 134, in __init__
    self.refresh()
  File "/usr/local/lib/python3.6/site-packages/beem/block.py", line 156, in refresh
    raise BlockDoesNotExistsException("output: %s of identifier %s" % (str(block), str(self.identifier)))
beem.exceptions.BlockDoesNotExistsException: output: {} of identifier 1000

Environment

# beempy --version
beempy, version 0.20.17
# python --version
Python 3.6.6

GitHub Account

https://github.com/crokkon

Sort:  

Hi @stmdev, thanks for making this contribution.

Your bug reports and pull requests have always played a major role in the development and improvement of the beem project. Beem is lucky to have you :)

I see you have fixed this and your pull request was merged. I would have loved for you to further throw light on what caused the error and the measures you took in rectifying it. I know there is a little note accompanying the PR.

Adding that to the Utopian posts will be of interest to some readers. Well, that's a small issue. It's a good find :)

Thanks again, I look forward to more of your reports.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

.

Thank you for your review, @fego! Keep up the good work!

Hey, @stmdev!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!