Make output of manage_clvm more readable on failure (#15658)
This commit is contained in:
parent
424c51072d
commit
4b77fb3dd1
|
@ -13,6 +13,8 @@ import typing
|
||||||
import click
|
import click
|
||||||
import typing_extensions
|
import typing_extensions
|
||||||
|
|
||||||
|
from chia.types.blockchain_format.sized_bytes import bytes32
|
||||||
|
|
||||||
here = pathlib.Path(__file__).parent.resolve()
|
here = pathlib.Path(__file__).parent.resolve()
|
||||||
root = here.parent
|
root = here.parent
|
||||||
cache_path = root.joinpath(".chia_cache", "manage_clvm.json")
|
cache_path = root.joinpath(".chia_cache", "manage_clvm.json")
|
||||||
|
@ -99,7 +101,7 @@ def dump_cache(cache: Cache, file: typing.IO[str]) -> None:
|
||||||
json.dump(cache, file, indent=4)
|
json.dump(cache, file, indent=4)
|
||||||
|
|
||||||
|
|
||||||
def generate_hash_bytes(hex_bytes: bytes) -> bytes:
|
def generate_hash_bytes(hex_bytes: bytes) -> bytes32:
|
||||||
cleaned_blob = bytes.fromhex(hex_bytes.decode("utf-8"))
|
cleaned_blob = bytes.fromhex(hex_bytes.decode("utf-8"))
|
||||||
serialize_program = SerializedProgram.from_bytes(cleaned_blob)
|
serialize_program = SerializedProgram.from_bytes(cleaned_blob)
|
||||||
return serialize_program.get_tree_hash()
|
return serialize_program.get_tree_hash()
|
||||||
|
@ -141,7 +143,7 @@ class ClvmBytes:
|
||||||
hex_bytes = paths.hex.read_bytes()
|
hex_bytes = paths.hex.read_bytes()
|
||||||
return cls(
|
return cls(
|
||||||
hex=hex_bytes,
|
hex=hex_bytes,
|
||||||
hash=bytes.fromhex(hash_dict[paths.hash])
|
hash=bytes32(bytes.fromhex(hash_dict[paths.hash]))
|
||||||
if paths.hash in hash_dict
|
if paths.hash in hash_dict
|
||||||
else generate_hash_bytes(hex_bytes=hex_bytes),
|
else generate_hash_bytes(hex_bytes=hex_bytes),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue