mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2025-01-08 18:34:27 +03:00
3b084a165b
* configure isort to add the future annotations import * apply the new isort setting * remove type ignores for new mypy (#13539) https://pypi.org/project/mypy/0.981/ * another
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Iterable, List
|
|
|
|
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
|
|
|
|
class IntegrityError(Exception):
|
|
pass
|
|
|
|
|
|
def build_message_with_hashes(message: str, bytes_objects: Iterable[bytes]) -> str:
|
|
return "\n".join([message, *[f" {b.hex()}" for b in bytes_objects]])
|
|
|
|
|
|
class TreeGenerationIncrementingError(IntegrityError):
|
|
def __init__(self, tree_ids: List[bytes32]) -> None:
|
|
super().__init__(
|
|
build_message_with_hashes(
|
|
message="Found trees with generations not properly incrementing:",
|
|
bytes_objects=tree_ids,
|
|
)
|
|
)
|
|
|
|
|
|
class NodeHashError(IntegrityError):
|
|
def __init__(self, node_hashes: List[bytes32]) -> None:
|
|
super().__init__(
|
|
build_message_with_hashes(
|
|
message="Found nodes with incorrect hashes:",
|
|
bytes_objects=node_hashes,
|
|
)
|
|
)
|
|
|
|
|
|
class KeyNotFoundError(Exception):
|
|
def __init__(self, key: bytes) -> None:
|
|
super().__init__(f"Key not found: {key.hex()}")
|
|
|
|
|
|
class OfferIntegrityError(Exception):
|
|
pass
|