HomePhabricator

[electrum] typehints and minor cleanup in blockchain.py

Description

[electrum] typehints and minor cleanup in blockchain.py

Summary:

  • Use an Enum for the chunk status for type safety and annotations
  • Add various typehints when the static analysis tools can't reliably guess from context
  • Refactor check_header and rename to get_chain_for_header. The return value is more than just a boolean, and it is treated as more than just a boolean by the callsites.

Test Plan:

python test_runner.py
pytest electrumabc/tests/regtest

Check that the CHUNK_* constants were not used anywhere except for checking the return status of Blockchain.connect_chunk and for log messages.

Run the software, send a transaction, wait for a new block.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
PiRKAuthored on Dec 8 2023, 06:42
PiRKPushed on Dec 8 2023, 13:15
Reviewer
Restricted Project
Differential Revision
D14950: [electrum] typehints and minor cleanup in blockchain.py
Parents
rABC40e6b84392b8: [electrum] typehints and minor cleanup in interface.py
Branches
Unknown
Tags
Unknown