Files
chia-blockchain/chia/plotters/chiapos.py
T
Kyle Altendorf 9c8557a1f8 Remove Python 3.8 support and update source to 3.9 standards (#18687)
* manual python 3.8 removals

* poetry

* pyupgrade

* black

* isort

* manually tidy imports

* work around shadowed type

* catch up build network protocol files for pyupgrade changes

* placate pylint

* re-enable 20.04

* placate flake8
2024-10-16 14:21:15 -07:00

64 lines
1.9 KiB
Python

"""
NOTE: This contains duplicate code from `chia.cmds.plots`.
After `chia plots create` becomes obsolete, consider removing it from there.
"""
from __future__ import annotations
import asyncio
import importlib.metadata
import logging
from argparse import Namespace
from pathlib import Path
from typing import Any, Optional
from chia.plotting.create_plots import create_plots, resolve_plot_keys
from chia.plotting.util import Params, add_plot_directory, validate_plot_size
log = logging.getLogger(__name__)
def get_chiapos_install_info() -> Optional[dict[str, Any]]:
chiapos_version = importlib.metadata.version("chiapos")
return {"display_name": "Chia Proof of Space", "version": chiapos_version, "installed": True}
def plot_chia(args: Namespace, root_path: Path) -> None:
try:
validate_plot_size(root_path, args.size, args.override)
except ValueError as e:
print(e)
return
plot_keys = asyncio.run(
resolve_plot_keys(
None if args.farmerkey == b"" else args.farmerkey.hex(),
args.alt_fingerprint,
None if args.pool_key == b"" else args.pool_key.hex(),
None if args.contract == "" else args.contract,
root_path,
log,
args.connect_to_daemon,
)
)
params = Params(
size=args.size,
num=args.count,
buffer=args.buffer,
num_threads=args.threads,
buckets=args.buckets,
stripe_size=args.stripes,
tmp_dir=Path(args.tmpdir),
tmp2_dir=Path(args.tmpdir2) if args.tmpdir2 else None,
final_dir=Path(args.finaldir),
plotid=args.id,
memo=args.memo,
nobitfield=args.nobitfield,
)
asyncio.run(create_plots(params, plot_keys))
if not args.exclude_final_dir:
try:
add_plot_directory(root_path, args.finaldir)
except ValueError as e:
print(e)