You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i am debugging an issue, and I had to log the json for the best results. what was annoying, is that I couldn't just turn on websockets debugging with their WEBSOCKETS_MAX_LOG_SIZE env variable, because web3.py is sending binary so it's log messages , so I decided to take a look.
for reference this is what logging in websockets looks like when you send in bytes instead of a str.
While looking around I found some room for improvement, happy to help if you think any of this is something you'd consider.
have provider.socket_send take a string, and let async_ipc encode to bytes, WebSocketProvider can just pass the string to websockets, which will do it's own encoding, and log in text instead of hex bytes which is what it does if you send bytes.
json.dumps should have the separartor=(',',':'). in _friendly_json_encode. no need to pad the network with 0x20's
FriendlyJsonSerde should just be turned into @classmethod, since there's no instance state. save the churn of creating these objects over and over as encode_rpc_request does.
since I think the point of FriendlyJsonSerde is to pinpoint failures if you happen to be encoding a dict like/list like object, shouldn't the encoder cls be passed to the recursive errors/encode calls?
encode_batch_rpc_request . it's handrolling json (in binary, with spaces :) ) because we do the transformation of RPCEndpoint/params into rpc_dict and json encoding in one step. if that rpc_dict was separated out, and especially since FriendlyJsonSerde does this recursive error mapping, it seems like we could just give FriendlyJsonSerde.json_encode a list of rpc_dicts and it would be fine. and the had coded json '[' ']' can be removed.
if any of this stuff is of interest for this project, I'm happy to submit a PR.
The text was updated successfully, but these errors were encountered:
What feature should we add?
i am debugging an issue, and I had to log the json for the best results. what was annoying, is that I couldn't just turn on websockets debugging with their WEBSOCKETS_MAX_LOG_SIZE env variable, because web3.py is sending binary so it's log messages , so I decided to take a look.
for reference this is what logging in websockets looks like when you send in bytes instead of a str.
While looking around I found some room for improvement, happy to help if you think any of this is something you'd consider.
cls
be passed to the recursive errors/encode calls?if any of this stuff is of interest for this project, I'm happy to submit a PR.
The text was updated successfully, but these errors were encountered: