refactor: remove miner factory cache.
This commit is contained in:
@@ -411,12 +411,6 @@ async def concurrent_get_first_result(tasks: list, verification_func: Callable):
|
|||||||
|
|
||||||
|
|
||||||
class MinerFactory:
|
class MinerFactory:
|
||||||
def __init__(self):
|
|
||||||
self.cache = {}
|
|
||||||
|
|
||||||
def clear_cached_miners(self):
|
|
||||||
self.cache = {}
|
|
||||||
|
|
||||||
async def get_multiple_miners(
|
async def get_multiple_miners(
|
||||||
self, ips: List[str], limit: int = 200
|
self, ips: List[str], limit: int = 200
|
||||||
) -> List[AnyMiner]:
|
) -> List[AnyMiner]:
|
||||||
@@ -442,8 +436,6 @@ class MinerFactory:
|
|||||||
|
|
||||||
async def get_miner(self, ip: str):
|
async def get_miner(self, ip: str):
|
||||||
ip = str(ip)
|
ip = str(ip)
|
||||||
if ip in self.cache:
|
|
||||||
return self.cache[ip]
|
|
||||||
|
|
||||||
miner_type = None
|
miner_type = None
|
||||||
|
|
||||||
@@ -491,8 +483,6 @@ class MinerFactory:
|
|||||||
miner_model=miner_model,
|
miner_model=miner_model,
|
||||||
)
|
)
|
||||||
|
|
||||||
if miner is not None and not isinstance(miner, UnknownMiner):
|
|
||||||
self.cache[ip] = miner
|
|
||||||
return miner
|
return miner
|
||||||
|
|
||||||
async def _get_miner_type(self, ip: str):
|
async def _get_miner_type(self, ip: str):
|
||||||
|
|||||||
@@ -120,9 +120,6 @@ class MinerNetwork:
|
|||||||
async def scan_network_for_miners(self) -> List[AnyMiner]:
|
async def scan_network_for_miners(self) -> List[AnyMiner]:
|
||||||
logging.debug(f"{self} - (Scan Network For Miners) - Scanning")
|
logging.debug(f"{self} - (Scan Network For Miners) - Scanning")
|
||||||
|
|
||||||
# clear cached miners
|
|
||||||
miner_factory.clear_cached_miners()
|
|
||||||
|
|
||||||
miners = await asyncio.gather(
|
miners = await asyncio.gather(
|
||||||
*[self.ping_and_get_miner(host) for host in self.hosts]
|
*[self.ping_and_get_miner(host) for host in self.hosts]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user