Page MenuHomePhabricator

[electrum] typehints and minor cleanup in blockchain.py
ClosedPublic

Authored by PiRK on Dec 8 2023, 06:51.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC78b72d91cb4a: [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.

Diff Detail

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

Event Timeline

PiRK requested review of this revision.Dec 8 2023, 06:51
PiRK planned changes to this revision.Dec 8 2023, 07:07

needs a few more typehints

use an alias for typehinting header dicts. This will make it easier to switch to a more typesafe Header in the future.
Add a few hints

better Header alias, deserialize_header nit

This revision is now accepted and ready to land.Dec 8 2023, 09:54