changed MinerFactory to a singleton class to ensure clearing its cache is easier and removed creation of independant miner factories for each utility

This commit is contained in:
UpstreamData
2022-03-16 12:05:44 -06:00
parent 57bd606f21
commit bae2ee4245
12 changed files with 37 additions and 49 deletions

View File

@@ -37,9 +37,19 @@ from settings import MINER_FACTORY_GET_VERSION_RETRIES as GET_VERSION_RETRIES
class MinerFactory:
_instance = None
def __init__(self):
self.miners = {}
def __new__(cls):
if not cls._instance:
cls._instance = super(
MinerFactory,
cls
).__new__(cls)
return cls._instance
async def get_miner_generator(self, ips: list):
"""
Get Miner objects from ip addresses using an async generator.