Skip to content

Commit

Permalink
Merge #35
Browse files Browse the repository at this point in the history
35: Correcting Height from str to int for node_util get_trusted_hash r=sacherjj a=sacherjj

Clean up of urllib call for rpc
Fix sending Height as str not int to RPC call, resulting on always getting latest block.

Co-authored-by: Joe Sacher <321623+sacherjj@users.noreply.github.com>
  • Loading branch information
casperlabs-bors-ng[bot] and sacherjj authored Jan 17, 2022
2 parents c93a6e0 + 9e14a21 commit 5e830e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resources/maintainer_scripts/node_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def _rpc_call(method: str, server: str, params: list, port: int = 7777, timeout:
req = request.Request(url, method="POST")
req.add_header('content-type', "application/json")
req.add_header('cache-control', "no-cache")
payload = json.dumps({"jsonrpc": "2.0", "method": method, "params": params, "id": 1}).encode()
r = request.urlopen(req, data=payload, timeout=timeout)
payload = json.dumps({"jsonrpc": "2.0", "method": method, "params": params, "id": 1}).encode('utf-8')
r = request.urlopen(req, payload, timeout=timeout)
json_data = json.loads(r.read())
return json_data["result"]

Expand All @@ -86,7 +86,7 @@ def _rpc_get_block(server: str, block_height=None, port: int = 7777, timeout: in
"""
params = []
if block_height:
params = [{"Height": block_height}]
params = [{"Height": int(block_height)}]
return NodeUtil._rpc_call("chain_get_block", server, params, port)

@staticmethod
Expand Down

0 comments on commit 5e830e2

Please sign in to comment.