Skip to content

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

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open

Update #349

wants to merge 41 commits into from

Conversation

olegudff
Copy link

No description provided.

mkdocs.yml Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be reverted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Copy link
Collaborator

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
Copy link
Collaborator

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.

Comment on lines 15 to 46
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)
Copy link
Collaborator

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"])].

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants