def __init__(self, executable): self._executable = executable self.__subscription = self._process = None self._randport = get_port() self.__address = ('127.0.0.1', self._randport) self._extra_args = [] # dict of algorithm name -> ESAlgorithm self._running_algorithms = {algorithm: ESAlgorithm(self, algorithm) for algorithm in ALGORITHMS} # dict of PCI bus id -> device id self._device_map = {} # dict of (algorithm name, Device instance) -> excavator worker id self._running_workers = {}
def __init__(self, executable): self._executable = executable self._region = self._auth = self._process = None self._address = ('127.0.0.1', get_port()) # dict of algorithm name -> ESAlgorithm self._running_algorithms = { algorithm: ESAlgorithm(self, algorithm) for algorithm in ALGORITHMS } # dict of PCI bus id -> device id self._device_map = {} # dict of (algorithm name, Device instance) -> excavator worker id self._running_workers = {}
def settings(self, v): self._region = v['nicehash']['region'] self._auth = '%s.%s:x' % (v['nicehash']['wallet'], v['nicehash']['workername']) # NOTE: Will break if the address is changed while excavator is running. if v['excavator_miner']['listen'] == '': self._address = ('127.0.0.1', get_port()) else: ip, port = v['excavator_miner']['listen'].split(':') self._address = (ip, port) if self._process is not None: # As of API 0.1.8, this changes strata but leaves all workers running. self._subscribe()
def start(self): """Launches excavator.""" assert self._process is None assert self._region is not None and self._auth is not None self._address = ('127.0.0.1', get_port()) # Start process. self._process = subprocess.Popen( [ self._executable, '-i', self._address[0], '-p', str(self._address[1]) ], stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, preexec_fn=os.setpgrp) # Don't forward signals. self._process.stdin.close() # Send stdout to logger. log_thread = threading.Thread(target=miner.log_output, args=(self._process, )) log_thread.start() # Wait for startup. while not self._test_connection(): if self._process.poll() is None: sleep(1) else: raise miner.MinerStartFailed self._read_devices() self._subscribe() # Add back previously running workers. for key, worker_id in self._running_workers.items(): algorithm, device = key self.start_work(algorithm, device)