docs: update docs.
This commit is contained in:
@@ -10,6 +10,7 @@ All API implementations inherit from [`BaseMinerAPI`][pyasic.API.BaseMinerAPI],
|
|||||||
[`BaseMinerAPI`][pyasic.API.BaseMinerAPI] cannot be instantiated directly, it will raise a `TypeError`.
|
[`BaseMinerAPI`][pyasic.API.BaseMinerAPI] cannot be instantiated directly, it will raise a `TypeError`.
|
||||||
Use these instead -
|
Use these instead -
|
||||||
|
|
||||||
|
#### [BFGMiner API][pyasic.API.bfgminer.BFGMinerAPI]
|
||||||
#### [BMMiner API][pyasic.API.bmminer.BMMinerAPI]
|
#### [BMMiner API][pyasic.API.bmminer.BMMinerAPI]
|
||||||
#### [BOSMiner API][pyasic.API.bosminer.BOSMinerAPI]
|
#### [BOSMiner API][pyasic.API.bosminer.BOSMinerAPI]
|
||||||
#### [BTMiner API][pyasic.API.btminer.BTMinerAPI]
|
#### [BTMiner API][pyasic.API.btminer.BTMinerAPI]
|
||||||
|
|||||||
7
docs/API/bfgminer.md
Normal file
7
docs/API/bfgminer.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# pyasic
|
||||||
|
## BFGMinerAPI
|
||||||
|
::: pyasic.API.bfgminer.BFGMinerAPI
|
||||||
|
handler: python
|
||||||
|
options:
|
||||||
|
show_root_heading: false
|
||||||
|
heading_level: 4
|
||||||
@@ -42,21 +42,27 @@ if __name__ == "__main__":
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Creating miners based on IP
|
## Creating miners based on IP
|
||||||
If you already know the IP address of your miner or miners, you can use the [`MinerFactory`][pyasic.miners.miner_factory.MinerFactory] to communicate and identify the miners.
|
If you already know the IP address of your miner or miners, you can use the [`MinerFactory`][pyasic.miners.miner_factory.MinerFactory] to communicate and identify the miners, or an abstraction of its functionality, [`get_miner()`][pyasic.miners.miner_factory.MinerFactory.get_miner].
|
||||||
The function [`MinerFactory().get_miner()`][pyasic.miners.miner_factory.MinerFactory.get_miner] will return any miner it found at the IP address specified, or an `UnknownMiner` if it cannot identify the miner.
|
The function [`get_miner()`][pyasic.miners.miner_factory.MinerFactory.get_miner] will return any miner it found at the IP address specified, or an `UnknownMiner` if it cannot identify the miner.
|
||||||
```python
|
```python
|
||||||
import asyncio # asyncio for handling the async part
|
import asyncio # asyncio for handling the async part
|
||||||
from pyasic.miners.miner_factory import MinerFactory # miner factory handles miners creation
|
from pyasic import get_miner # handles miner creation
|
||||||
|
|
||||||
|
|
||||||
async def get_miners(): # define async scan function to allow awaiting
|
async def get_miners(): # define async scan function to allow awaiting
|
||||||
# get the miner with miner factory
|
# get the miner with the miner factory
|
||||||
# miner factory is a singleton, and will always use the same object and cache
|
# the miner factory is a singleton, and will always use the same object and cache
|
||||||
# this means you can always call it as MinerFactory().get_miner()
|
# this means you can always call it as MinerFactory().get_miner(), or just get_miner()
|
||||||
miner_1 = await MinerFactory().get_miner("192.168.1.75")
|
miner_1 = await get_miner("192.168.1.75")
|
||||||
miner_2 = await MinerFactory().get_miner("192.168.1.76")
|
miner_2 = await get_miner("192.168.1.76")
|
||||||
print(miner_1, miner_2)
|
print(miner_1, miner_2)
|
||||||
|
|
||||||
|
# can also gather these, since they are async
|
||||||
|
tasks = [get_miner("192.168.1.75"), get_miner("192.168.1.76")]
|
||||||
|
miners = await asyncio.gather(*tasks)
|
||||||
|
print(miners)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(get_miners()) # get the miners asynchronously with asyncio.run()
|
asyncio.run(get_miners()) # get the miners asynchronously with asyncio.run()
|
||||||
```
|
```
|
||||||
@@ -66,7 +72,7 @@ if __name__ == "__main__":
|
|||||||
## Getting data from miners
|
## Getting data from miners
|
||||||
|
|
||||||
Once you have your miner(s) identified, you will likely want to get data from the miner(s). You can do this using a built in function in each miner called `get_data()`.
|
Once you have your miner(s) identified, you will likely want to get data from the miner(s). You can do this using a built in function in each miner called `get_data()`.
|
||||||
This function will return a instance of the dataclass [`MinerData`][pyasic.data.MinerData] with all data it can gather from the miner.
|
This function will return an instance of the dataclass [`MinerData`][pyasic.data.MinerData] with all data it can gather from the miner.
|
||||||
Each piece of data in a [`MinerData`][pyasic.data.MinerData] instance can be referenced by getting it as an attribute, such as [`MinerData().hashrate`][pyasic.data.MinerData].
|
Each piece of data in a [`MinerData`][pyasic.data.MinerData] instance can be referenced by getting it as an attribute, such as [`MinerData().hashrate`][pyasic.data.MinerData].
|
||||||
```python
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# pyasic
|
# pyasic
|
||||||
## BFGMiner Backend
|
## BFGMiner Backend
|
||||||
|
|
||||||
::: pyasic.miners.kda._backends.bfgminer.BFGMiner
|
::: pyasic.miners.backends.bfgminer.BFGMiner
|
||||||
handler: python
|
handler: python
|
||||||
options:
|
options:
|
||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
|
|||||||
36
mkdocs.yml
36
mkdocs.yml
@@ -1,10 +1,26 @@
|
|||||||
site_name: pyasic
|
site_name: pyasic
|
||||||
repo_url: https://github.com/UpstreamData/pyasic
|
repo_url: https://github.com/UpstreamData/pyasic
|
||||||
nav:
|
nav:
|
||||||
- Introduction: "index.md"
|
- Introduction: "index.md"
|
||||||
- Miners:
|
- Miners:
|
||||||
- Supported Miners: "miners/supported_types.md"
|
- Supported Miners: "miners/supported_types.md"
|
||||||
- Miner Factory: "miners/miner_factory.md"
|
- Miner Factory: "miners/miner_factory.md"
|
||||||
|
- Network:
|
||||||
|
- Miner Network: "network/miner_network.md"
|
||||||
|
- Miner Network Range: "network/miner_network_range.md"
|
||||||
|
- Dataclasses:
|
||||||
|
- Miner Data: "data/miner_data.md"
|
||||||
|
- Error Codes: "data/error_codes.md"
|
||||||
|
- Miner Config: "config/miner_config.md"
|
||||||
|
- Advanced:
|
||||||
|
- Miner APIs:
|
||||||
|
- Intro: "API/api.md"
|
||||||
|
- BFGMiner: "API/bfgminer.md"
|
||||||
|
- BMMiner: "API/bmminer.md"
|
||||||
|
- BOSMiner: "API/bosminer.md"
|
||||||
|
- BTMiner: "API/btminer.md"
|
||||||
|
- CGMiner: "API/cgminer.md"
|
||||||
|
- Unknown: "API/unknown.md"
|
||||||
- Backends:
|
- Backends:
|
||||||
- BMMiner: "miners/backends/bmminer.md"
|
- BMMiner: "miners/backends/bmminer.md"
|
||||||
- BOSMiner: "miners/backends/bosminer.md"
|
- BOSMiner: "miners/backends/bosminer.md"
|
||||||
@@ -32,22 +48,6 @@ nav:
|
|||||||
- Goldshell CKX: "miners/goldshell/CKX.md"
|
- Goldshell CKX: "miners/goldshell/CKX.md"
|
||||||
- Goldshell HSX: "miners/goldshell/HSX.md"
|
- Goldshell HSX: "miners/goldshell/HSX.md"
|
||||||
- Goldshell KDX: "miners/goldshell/KDX.md"
|
- Goldshell KDX: "miners/goldshell/KDX.md"
|
||||||
- Network:
|
|
||||||
- Miner Network: "network/miner_network.md"
|
|
||||||
- Miner Network Range: "network/miner_network_range.md"
|
|
||||||
- Dataclasses:
|
|
||||||
- Miner Data: "data/miner_data.md"
|
|
||||||
- Error Codes: "data/error_codes.md"
|
|
||||||
- Miner Config: "config/miner_config.md"
|
|
||||||
- Advanced:
|
|
||||||
- Miner APIs:
|
|
||||||
- Intro: "API/api.md"
|
|
||||||
- BMMiner: "API/bmminer.md"
|
|
||||||
- BOSMiner: "API/bosminer.md"
|
|
||||||
- BTMiner: "API/btminer.md"
|
|
||||||
- CGMiner: "API/cgminer.md"
|
|
||||||
- Unknown: "API/unknown.md"
|
|
||||||
|
|
||||||
- Base Miner: "miners/base_miner.md"
|
- Base Miner: "miners/base_miner.md"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ MINER_CLASSES = {
|
|||||||
|
|
||||||
|
|
||||||
class MinerFactory(metaclass=Singleton):
|
class MinerFactory(metaclass=Singleton):
|
||||||
"""A factory to handle identification and selection of the proper class of miner"""
|
"""A factory to handle identification and selection of the proper class of miner."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.miners = {}
|
self.miners = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user