from substrateinterface import SubstrateInterface
substrate = SubstrateInterface(
url="wss://rpc.polkadot.io"
)
def new_block(obj, update_nr, subscription_id):
print(obj['header']['parentHash'])
result = substrate.subscribe_block_headers(subscription_handler=new_block)
but when I add include_author=True to subscribe_block_headers I get the following :
Traceback (most recent call last):
File "/root/py-subalert/test.py", line 10, in <module>
result = substrate.subscribe_block_headers(new_block, include_author=True)
File "/usr/local/lib/python3.9/dist-packages/substrateinterface/base.py", line 2427, in subscribe_block_headers
return self.__get_block_handler(
File "/usr/local/lib/python3.9/dist-packages/substrateinterface/utils/caching.py", line 38, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/substrateinterface/base.py", line 2280, in __get_block_handler
result = self.rpc_request(f"chain_subscribe{rpc_method_prefix}Heads", [], result_handler=result_handler)
File "/usr/local/lib/python3.9/dist-packages/substrateinterface/base.py", line 567, in rpc_request
callback_result = result_handler(message, update_nr, subscription_id)
File "/usr/local/lib/python3.9/dist-packages/substrateinterface/base.py", line 2270, in result_handler
new_block = decode_block({'header': message['params']['result']})
File "/usr/local/lib/python3.9/dist-packages/substrateinterface/base.py", line 2246, in decode_block
if log_digest.value['PreRuntime']['engine'] == 'BABE':
TypeError: tuple indices must be integers or slices, not str
The code below works
but when I add
include_author=True
to subscribe_block_headers I get the following :python: 3.9 scalecodec: 1.0.6 substrate-interface: 1.0.2
Does this reproduce for anyone else?