@@ -1718,16 +1718,18 @@ def rpc_request(
17181718 self ,
17191719 method : str ,
17201720 params : Optional [list ],
1721+ result_handler : Optional [Callable ] = None ,
17211722 block_hash : Optional [str ] = None ,
17221723 reuse_block_hash : bool = False ,
17231724 ) -> Any :
17241725 """
1725- Makes an RPC request to the subtensor. Use this only if `self.query`` and `self.query_multiple` and
1726+ Makes an RPC request to the subtensor. Use this only if `self.query` and `self.query_multiple` and
17261727 `self.query_map` do not meet your needs.
17271728
17281729 Args:
17291730 method: str the method in the RPC request
17301731 params: list of the params in the RPC request
1732+ result_handler: Callback function that processes the result received from the node
17311733 block_hash: the hash of the block — only supply this if not supplying the block
17321734 hash in the params, and not reusing the block hash
17331735 reuse_block_hash: whether to reuse the block hash in the params — only mark as True
@@ -1746,7 +1748,7 @@ def rpc_request(
17461748 params + [block_hash ] if block_hash else params ,
17471749 )
17481750 ]
1749- result = self ._make_rpc_request (payloads )
1751+ result = self ._make_rpc_request (payloads , result_handler = result_handler )
17501752 if "error" in result [payload_id ][0 ]:
17511753 if (
17521754 "Failed to get runtime version"
@@ -1756,7 +1758,9 @@ def rpc_request(
17561758 "Failed to get runtime. Re-fetching from chain, and retrying."
17571759 )
17581760 self .init_runtime ()
1759- return self .rpc_request (method , params , block_hash , reuse_block_hash )
1761+ return self .rpc_request (
1762+ method , params , result_handler , block_hash , reuse_block_hash
1763+ )
17601764 raise SubstrateRequestException (result [payload_id ][0 ]["error" ]["message" ])
17611765 if "result" in result [payload_id ][0 ]:
17621766 return result [payload_id ][0 ]
@@ -1776,7 +1780,6 @@ def get_chain_head(self) -> str:
17761780 )
17771781 ]
17781782 )
1779- print (1779 , result )
17801783 self .last_block_hash = result ["rpc_request" ][0 ]["result" ]
17811784 return result ["rpc_request" ][0 ]["result" ]
17821785
@@ -2577,12 +2580,12 @@ def query_map(
25772580 ```
25782581 result = substrate.query_map('System', 'Account', max_results=100)
25792582
2580- async for account, account_info in result:
2583+ for account, account_info in result:
25812584 print(f"Free balance of account '{account.value}': {account_info.value['data']['free']}")
25822585 ```
25832586
25842587 Note: it is important that you do not use `for x in result.records`, as this will sidestep possible
2585- pagination. You must do `async for x in result`.
2588+ pagination. You must do `for x in result`.
25862589
25872590 Args:
25882591 module: The module name in the metadata, e.g. System or Balances.
0 commit comments