-
Notifications
You must be signed in to change notification settings - Fork 78
Update #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update #349
Conversation
# Conflicts: # pyasic/device/models.py # pyasic/miners/antminer/bmminer/X21/S21.py # pyasic/miners/antminer/bmminer/X21/__init__.py # pyasic/miners/backends/antminer.py # pyasic/miners/device/models/antminer/X21/S21.py # pyasic/miners/device/models/antminer/X21/__init__.py # pyproject.toml
mkdocs.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be reverted.
pyasic/__init__.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
pyasic/data/__init__.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
Regarding the is_sleep
parameter, that should be parsed as part of the config and/or is_mining
, config.mining_mode = MiningModeSleep()
in this case.
""" | ||
|
||
speed: int = None | ||
max_speed: Optional[int] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use int | None
here, I will update the supported versions to >=3.10
to guarantee support for this.
class PoolUrl(BaseModel): | ||
scheme: Scheme | ||
host: str | ||
port: int | ||
port: Optional[int] = None | ||
pubkey: Optional[str] = None | ||
|
||
@model_serializer | ||
def serialize(self): | ||
return str(self) | ||
|
||
def __str__(self) -> str: | ||
port_str = f":{self.port}" if self.port is not None else "" | ||
if self.scheme == Scheme.STRATUM_V2 and self.pubkey: | ||
return f"{self.scheme.value}://{self.host}:{self.port}/{self.pubkey}" | ||
return f"{self.scheme.value}://{self.host}{port_str}/{self.pubkey}" | ||
else: | ||
return f"{self.scheme.value}://{self.host}:{self.port}" | ||
return f"{self.scheme.value}://{self.host}{port_str}" | ||
|
||
@classmethod | ||
def from_str(cls, url: str) -> Self | None: | ||
parsed_url = urlparse(url) | ||
if not parsed_url.hostname: | ||
return None | ||
if not parsed_url.scheme.strip() == "": | ||
scheme = Scheme(parsed_url.scheme) | ||
else: | ||
scheme = Scheme.STRATUM_V1 | ||
# Если схема отсутствует, используем схему по умолчанию | ||
scheme = ( | ||
Scheme(parsed_url.scheme) | ||
if parsed_url.scheme.strip() != "" | ||
else Scheme.STRATUM_V1 | ||
) | ||
host = parsed_url.hostname | ||
port = parsed_url.port | ||
port = parsed_url.port # может быть None, если порт не указан | ||
pubkey = parsed_url.path.lstrip("/") if scheme == Scheme.STRATUM_V2 else None | ||
return cls(scheme=scheme, host=host, port=port, pubkey=pubkey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may end up just replacing this with a pydantic type, learned recently that this is actually fully supported, so rather than this I can just use PoolUrl = Annotated[Url, UrlConstraints(host_required=True, allowed_schemes=["stratum+tcp", "stratum2+tcp", "stratum+ssl"])]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
tests/test_data.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
for more information, see https://pre-commit.ci
# Conflicts: # pyasic/test.py
for more information, see https://pre-commit.ci
No description provided.