HomePhabricator

[electrum] move JSON related classes and function from util to json_util

Description

[electrum] move JSON related classes and function from util to json_util

Summary:
This fixes a util.py -> transaction.py -> util.py circular import, which was previously "fixed" in a hacky way by importing transaction.py in MyEncoder

util.py is imported almost everywhere, so it should import as few other modules as possible.

This commit is move-mostly, with two minor fixups flagged by PyCharm:

  • rename socket -> sock in the JSONSocketPipe.__init__ args to avoid shadowing the socket module from the outer scope
  • simplify chained comparison: if self.max_message_bytes > 0 and len(self.recv_buf) > self.max_message_bytes: -> if 0 < self.max_message_bytes < len(self.recv_buf):

Test Plan: python test_runner.py

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14240

Details

Provenance
PiRKAuthored on Jul 10 2023, 07:28
PiRKPushed on Jul 10 2023, 19:14
Reviewer
Restricted Project
Differential Revision
D14240: [electrum] move JSON related classes and function from util to json_util
Parents
rABC1c058cec5250: [ecash-herald] Use saved mocks if available
Branches
Unknown
Tags
Unknown