XMRigManager
A class to manage multiple XMRig miners via their APIs.
Attributes:
Name | Type | Description |
---|---|---|
_miners |
Dict[str, XMRigAPI]
|
A dictionary to store miner API instances. |
_api_factory |
Callable[..., XMRigAPI]
|
Factory for creating XMRigAPI instances. |
_db_url |
str
|
Database URL for storing miner data. |
Source code in xmrig/manager.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
__init__(api_factory=XMRigAPI, db_url='sqlite:///xmrig-api.db')
Initializes the manager with an empty collection of miners.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_factory
|
Callable
|
Factory for creating XMRigAPI instances. |
XMRigAPI
|
db_url
|
str
|
Database URL for storing miner data. |
'sqlite:///xmrig-api.db'
|
Source code in xmrig/manager.py
add_miner(miner_name, ip, port, access_token=None, tls_enabled=False)
Adds a new miner to the manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
miner_name
|
str
|
A unique name for the miner. |
required |
ip
|
str
|
IP address or domain of the XMRig API. |
required |
port
|
int
|
Port of the XMRig API. |
required |
access_token
|
Optional[str]
|
Access token for authorization. Defaults to None. |
None
|
tls_enabled
|
bool
|
TLS status of the miner/API. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
XMRigManagerError
|
If an error occurs while adding the miner. |
Source code in xmrig/manager.py
edit_miner(miner_name, new_details)
Edits the details of a miner. The following details can be edited:
- miner_name (str): A unique name for the miner.
- ip (str): IP address or domain of the XMRig API.
- port (str): Port of the XMRig API.
- access_token (Optional[str]): Access token for authorization.
- tls_enabled (bool): TLS status of the miner/API.
The dictionary can be in any order and can contain any number of the above keys. For example:
full_details = { 'miner_name': 'new_name', 'ip': 'new_ip_or_domain_with_tld', 'port': '1234', 'access_token': 'new-token', 'tls_enabled': True }
partial_details = { 'miner_name': 'new_name', 'port': '1234' }
Parameters:
Name | Type | Description | Default |
---|---|---|---|
miner_name
|
str
|
The unique name of the miner. |
required |
new_details
|
dict
|
The new details for the miner. |
required |
Raises:
Type | Description |
---|---|
XMRigManagerError
|
If an error occurs while editing the miner. |
Source code in xmrig/manager.py
get_miner(miner_name)
Retrieves a specific miner's API instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
miner_name
|
str
|
The unique name of the miner. |
required |
Returns:
Name | Type | Description |
---|---|---|
XMRigAPI |
XMRigAPI
|
The API instance for the requested miner. |
Raises:
Type | Description |
---|---|
XMRigManagerError
|
If an error occurs while retrieving the miner. |
Source code in xmrig/manager.py
list_miners()
Lists all managed miners.
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of miner names. |
perform_action_on_all(action)
Performs the specified action on all miners.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
str
|
The action to perform ('pause', 'resume', 'stop', 'start'). |
required |
Raises:
Type | Description |
---|---|
XMRigManagerError
|
If an error occurs while performing the action on all miners. |
Source code in xmrig/manager.py
remove_miner(miner_name)
Removes a miner from the manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
miner_name
|
str
|
The unique name of the miner to remove. |
required |
Raises:
Type | Description |
---|---|
XMRigManagerError
|
If an error occurs while removing the miner. |
Source code in xmrig/manager.py
update_miners(endpoint=None)
Updates all miners' cached data or calls a specific endpoint on all miners.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint
|
Optional[str]
|
The endpoint to call on each miner. If None, updates all cached data. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if successful, or False if an error occurred. |
Raises:
Type | Description |
---|---|
XMRigManagerError
|
If an error occurs while updating the miners or calling the endpoint. |