def check(self): log.debug('datadir', datadir=self['datadir']) if (self['datadir'] is None or not os.path.exists(self['datadir'])): self.autoconfigure_datadir() if os.path.exists(os.path.join(self['datadir'], 'blocks')): if self['prune'] is None: self.set_prune(False) else: if self['prune'] is None: should_prune = self.hard_drives.should_prune(self['datadir']) self.set_prune(should_prune) self.wallet_paths = self.get_wallet_paths() if self['server'] is None: self['server'] = True if self['disablewallet'] is None and not self.wallet_paths: self['disablewallet'] = True elif self['disablewallet'] is None and self.wallet_paths: self['disablewallet'] = False if self['timeout'] is None: self['timeout'] = 6000 if self['rpcuser'] is None: self['rpcuser'] = '******' if self['rpcpassword'] is None: self['rpcpassword'] = get_random_password() self.zmq_block_port = get_zmq_port() self.zmq_tx_port = get_zmq_port() self['zmqpubrawblock'] = f'tcp://127.0.0.1:{self.zmq_block_port}' self['zmqpubrawtx'] = f'tcp://127.0.0.1:{self.zmq_tx_port}' self['proxy'] = '127.0.0.1:9050' self['listen'] = True self['bind'] = '127.0.0.1' self['debug'] = 'tor' self['discover'] = True # noinspection PyBroadException try: memory = psutil.virtual_memory() free_mb = round(memory.available / 1000000) free_mb -= int(free_mb * .3) if 'dbcache' in self: del self['dbcache'] self['dbcache'] = min(free_mb, 10000) self['maxmempool'] = 500 self['mempoolexpiry'] = 2000 except: log.warning('dbcache psutil.virtual_memory', exc_info=True) self['dbcache'] = 1000
def check(self): log.debug('datadir', datadir=self.file['datadir']) if (self.file['datadir'] is None or not os.path.exists(self.file['datadir'])): self.autoconfigure_datadir() if 'bitcoin.conf' in os.listdir(self.file['datadir']): actual_conf_file = os.path.join(self.file['datadir'], 'bitcoin.conf') if self.file_path != actual_conf_file: log.info('datadir_redirect', configuration_file_path=self.file_path, actual_conf_file=actual_conf_file) self.file = ConfigurationFile(actual_conf_file) if (self.file['datadir'] is None or not os.path.exists(self.file['datadir'])): self.autoconfigure_datadir() if os.path.exists(os.path.join(self.file['datadir'], 'blocks')): if self.file['prune'] is None: self.set_prune(False) self.wallet_paths = self.get_wallet_paths() if self.file['server'] is None: self.file['server'] = True if self.file['disablewallet'] is None and not self.wallet_paths: self.file['disablewallet'] = True elif self.file['disablewallet'] is None and self.wallet_paths: self.file['disablewallet'] = False if self.file['timeout'] is None: self.file['timeout'] = 6000 if self.file['rpcuser'] is None: self.file['rpcuser'] = '******' if self.file['rpcpassword'] is None: self.file['rpcpassword'] = get_random_password() if self.file['prune'] is None: should_prune = self.hard_drives.should_prune(self.file['datadir'], has_bitcoin=True) self.set_prune(should_prune) self.zmq_block_port = get_zmq_port() self.zmq_tx_port = get_zmq_port() self.file['zmqpubrawblock'] = f'tcp://127.0.0.1:{self.zmq_block_port}' self.file['zmqpubrawtx'] = f'tcp://127.0.0.1:{self.zmq_tx_port}' self.file['proxy'] = '127.0.0.1:9050' self.file['listen'] = True self.file['bind'] = '127.0.0.1' self.file['debug'] = 'tor' self.file['discover'] = True # noinspection PyBroadException try: memory = psutil.virtual_memory() free_mb = round(memory.available / 1000000) free_mb -= int(free_mb * .3) self.file['dbcache'] = free_mb except: log.warning('dbcache psutil.virtual_memory', exc_info=True) self.file['dbcache'] = 1000 self.config_snapshot = self.file.snapshot.copy()