Page MenuHomePhabricator

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

Authored by PiRK on Jul 10 2023, 07:46.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable