blockchain.stream and blockchain.ops are missing virtual operations

in #utopian-io6 years ago (edited)

Expected behavior

blockchain.stream() and blockchain.ops() should stream both regular and virtual Steem operations. Via optional arguments, it should be possible to stream only virtual operations.

Actual behavior

blockchain.stream() and blockchain.ops() only stream regular operations. Virtual ops like author_reward, curation_reward and others are not contained in the stream.

blockchain.ops() lists an optional parameter only_virtual_ops. If set, blockchain.ops() fails with

TypeError: blocks() got an unexpected keyword argument 'only_virtual_ops'

How to reproduce

from beem import Steem
from beem.blockchain import Blockchain
s = Steem(node='https://rpc.buildteam.io')
b = Blockchain(s)
for op in b.stream():
    if op['type'] == "author_reward":
        print(op)
        break

This script never completes, because none of the ops yielded by stream() is a (virtual) "author_reward" op.

The same code with steem-python completes within seconds:

from steem import Steem
from steem.blockchain import Blockchain
s = Steem(nodes=['https://rpc.buildteam.io'])
b = Blockchain(s)
for op in b.stream():
    if op['type'] == "author_reward":  
        print(op)
        break
Stacktrace for virtual_ops_only
>>> from beem.blockchain import Blockchain
>>> b = Blockchain()
>>> for op in b.ops(virtual_ops_only=True):
...     print(op)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/beem/blockchain.py", line 323, in ops
    for block in self.blocks(start=start, stop=stop, **kwargs):
TypeError: blocks() got an unexpected keyword argument 'virtual_ops_only'
Environment
# python --version
Python 3.6.4
# beempy --version
beempy, version 0.19.26
# steempy --version
steempy 1.0.0
Sort:  

Thanks for the contribution it has been approved !


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

hi @cha0s0000, author_reward is a block chain operation type that should come out of blockchain.stream(). only_virtual_ops is an option to blockchain.stream(), see here.
I've been in contact with the PO who confirmed this is a bug.

Hello @stmdev. Due to a small delay in reviewing and upvoting this contribution, this comment has been upvoted instead.

give me some mins to check it !Thank you !

The docu says that ops() should return also virtual operations:

ops(start=None, stop=None, **kwargs)
Yields all operations (including virtual operations) starting from start.

Parameters: 
start (int) – Starting block
stop (int) – Stop at this block
mode (str) – We here have the choice between “head” (the last block) and “irreversible” (the block that is confirmed by 2/3 of all block producers and is thus irreversible)
only_virtual_ops (bool) – Only yield virtual operations

but does not. So it is a valid bug report to me.

give me some mins to check it !

Hey @stmdev
Thanks for contributing on Utopian.
We're already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

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

Vote for Utopian Witness!

Congratulations @stmdev! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.028
BTC 54357.85
ETH 2282.80
USDT 1.00
SBD 2.31