Moved all communicator ext vars to KV
This commit is contained in:
parent
f28d469e56
commit
5bde99967b
@ -57,7 +57,6 @@ class OnionrCommunicatorDaemon:
|
|||||||
|
|
||||||
# configure logger and stuff
|
# configure logger and stuff
|
||||||
self.config = config
|
self.config = config
|
||||||
self.isOnline = True # Assume we're connected to the internet
|
|
||||||
self.shared_state = shared_state # TooManyObjects module
|
self.shared_state = shared_state # TooManyObjects module
|
||||||
|
|
||||||
# populate kv values
|
# populate kv values
|
||||||
@ -77,9 +76,10 @@ class OnionrCommunicatorDaemon:
|
|||||||
self.kv.put('generating_blocks', [])
|
self.kv.put('generating_blocks', [])
|
||||||
self.kv.put('lastNodeSeen', None)
|
self.kv.put('lastNodeSeen', None)
|
||||||
self.kv.put('startTime', epoch.get_epoch())
|
self.kv.put('startTime', epoch.get_epoch())
|
||||||
|
self.kv.put('isOnline', True)
|
||||||
|
|
||||||
if config.get('general.offline_mode', False):
|
if config.get('general.offline_mode', False):
|
||||||
self.isOnline = False
|
self.kv.put('isOnline', False)
|
||||||
|
|
||||||
# list of timer instances
|
# list of timer instances
|
||||||
self.timers = []
|
self.timers = []
|
||||||
|
@ -63,7 +63,7 @@ def download_blocks_from_communicator(comm_inst: "OnionrCommunicatorDaemon"):
|
|||||||
if not shoulddownload.should_download(comm_inst, blockHash):
|
if not shoulddownload.should_download(comm_inst, blockHash):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if kv.get('shutdown') or not comm_inst.isOnline or \
|
if kv.get('shutdown') or not kv.get('isOnline') or \
|
||||||
storage_counter.is_full():
|
storage_counter.is_full():
|
||||||
# Exit loop if shutting down or offline, or disk allocation reached
|
# Exit loop if shutting down or offline, or disk allocation reached
|
||||||
break
|
break
|
||||||
|
@ -56,7 +56,7 @@ def lookup_blocks_from_communicator(comm_inst):
|
|||||||
listLookupCommand = 'getblocklist'
|
listLookupCommand = 'getblocklist'
|
||||||
if len(kv.get('blockQueue')) >= maxBacklog:
|
if len(kv.get('blockQueue')) >= maxBacklog:
|
||||||
break
|
break
|
||||||
if not comm_inst.isOnline:
|
if not kv.get('isOnline'):
|
||||||
break
|
break
|
||||||
# check if disk allocation is used
|
# check if disk allocation is used
|
||||||
if storage_counter.is_full():
|
if storage_counter.is_full():
|
||||||
|
@ -42,7 +42,7 @@ def net_check(comm_inst):
|
|||||||
try:
|
try:
|
||||||
if (epoch.get_epoch() - int(localcommand.local_command
|
if (epoch.get_epoch() - int(localcommand.local_command
|
||||||
('/lastconnect'))) <= 60:
|
('/lastconnect'))) <= 60:
|
||||||
comm_inst.isOnline = True
|
kv.put('isOnline', True)
|
||||||
rec = True
|
rec = True
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
@ -55,7 +55,7 @@ def net_check(comm_inst):
|
|||||||
terminal=True)
|
terminal=True)
|
||||||
restarttor.restart(comm_inst)
|
restarttor.restart(comm_inst)
|
||||||
kv.put('offlinePeers', [])
|
kv.put('offlinePeers', [])
|
||||||
comm_inst.isOnline = False
|
kv.put('isOnline', False)
|
||||||
else:
|
else:
|
||||||
comm_inst.isOnline = True
|
kv.put('isOnline', True)
|
||||||
comm_inst.decrementThreadCount('net_check')
|
comm_inst.decrementThreadCount('net_check')
|
||||||
|
Loading…
Reference in New Issue
Block a user