Beem-0.20.12: unable to use Blockchain.stream()/blocks() with only_ops=True and threads

in #utopian-io6 years ago

Project Information

A GitHub issue and a PR to fix the problem were provided and merged to master. The fix will be included in the next release.

Expected result

Blockchain.stream/blocks(start, stop, only_ops=True) should return all ops in the given block range. Additionally using threading=True should eventually speed things up.

Actual result

Blockchain.stream/blocks(start, stop, only_ops=True, threading=True) prints errors

int() argument must be a string, a bytes-like object or a number, not 'NoneType'

and never completes.

How to reproduce

from beem.blockchain import Blockchain
b = Blockchain()
for op in b.blocks(start=25000000, stop=25000010, only_ops=True,
                   threading=True):
    continue

Output:

int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
...

Cause/Fix

When only_ops=False (default), beem uses the get_block API call. The get_block() answer contains the block_id field, which is correctly parsed by Block.block_num here.

When only_ops=True, beem uses the get_ops_in_block API call, which also includes virtual operations (e.g. author/curation rewards etc.) The get_ops_in_block() answer, however, does not contain a block_id field. Calling Block.block_num on this data returns None, causing the threads bookkeeping logic to fail to register the received block data. The Blockchain.blocks() logic then endlessly retries to fetch the corresponding block data.

The get_ops_in_block() answer contains the corresponding block number in a block field. By adding a check for the block field into the Block.block_num method, both cases can be treated correctly and Blockchain.blocks() doesn't run into int(None) errors anymore here.

Environment

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

GitHub Account

https://github.com/crokkon

Sort:  

Hi @stmdev, thanks for making this contribution.

I see the issue has been fixed in the pull request made by you. I like that you provided with the report a technical analysis, detailing what led to the error.

  1. The post title is exactly as it should be, with just enough information to give the PO a glimpse to what possibly went wrong.

  2. I like how well you identified the difference in behavior between what is expected and what is actually gotten.

  3. The steps you provided were clear as day and quite easy to walk through.

  4. I also like that you included a technical analysis, proposed a fix and then went on to make a pull request to that effect. Great job.

This report adds significant value to the open source community and is reflected in my scoring.

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? Write a ticket on https://support.utopian.io/.
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!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63178.17
ETH 2581.50
USDT 1.00
SBD 2.71