1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00

Added json.dumps to Python example RPC examples

As suggested in https://github.com/romanz/electrs/pull/415#issuecomment-870345086 `json.dumps` is added in-place of a manual construction of a request message.
This commit is contained in:
moneroexamples 2021-06-29 17:00:22 +08:00 committed by GitHub
parent 955910cca3
commit 6caf8017af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -458,7 +458,8 @@ import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(("127.0.0.1", 50001))
f = s.makefile()
s.sendall(b'{"jsonrpc": "2.0", "method": "server.version", "params": ["", "1.4"], "id": 0}\n')
message = json.dumps({"jsonrpc": "2.0", "method": "server.version", "params": ["", "1.4"], "id": "0"})
s.sendall((message + '\n').encode())
print(json.loads(f.readline()))
```