moved all but shutdown over to new daemon events system
This commit is contained in:
parent
c975d27906
commit
a801960179
11 changed files with 76 additions and 204 deletions
|
@ -1,69 +0,0 @@
|
|||
"""Onionr - P2P Anonymous Storage Network.
|
||||
|
||||
Handle daemon queue commands in the communicator
|
||||
"""
|
||||
import logger
|
||||
from onionrplugins import onionrevents as events
|
||||
from onionrutils import localcommand
|
||||
from coredb import daemonqueue
|
||||
import filepaths
|
||||
from . import restarttor
|
||||
from communicatorutils.uploadblocks import mixmate
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def handle_daemon_commands(comm_inst):
|
||||
# Deprecated in favor of daemon events
|
||||
cmd = daemonqueue.daemon_queue()
|
||||
response = ''
|
||||
if cmd is not False:
|
||||
events.event('daemon_command', data = {'cmd': cmd})
|
||||
if cmd[0] == 'shutdown':
|
||||
comm_inst.shutdown = True
|
||||
elif cmd[0] == 'runtimeTest':
|
||||
comm_inst.shared_state.get_by_string(
|
||||
"OnionrRunTestManager").run_tests()
|
||||
elif cmd[0] == 'remove_from_insert_list':
|
||||
try:
|
||||
comm_inst.generating_blocks.remove(cmd[1])
|
||||
except ValueError:
|
||||
pass
|
||||
elif cmd[0] == 'restartTor':
|
||||
restarttor.restart(comm_inst)
|
||||
comm_inst.offlinePeers = []
|
||||
elif cmd[0] == 'uploadBlock':
|
||||
comm_inst.blocksToUpload.append(cmd[1])
|
||||
elif cmd[0] == 'uploadEvent':
|
||||
try:
|
||||
mixmate.block_mixer(comm_inst.blocksToUpload, cmd[1])
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
localcommand.local_command(
|
||||
'/waitforshare/' + cmd[1], post=True, maxWait=5)
|
||||
else:
|
||||
logger.debug(
|
||||
'Received daemon queue command unable to be handled: %s' %
|
||||
(cmd[0],))
|
||||
|
||||
if cmd[0] not in ('', None):
|
||||
if response != '':
|
||||
localcommand.local_command(
|
||||
'queueResponseAdd/' + cmd[4],
|
||||
post=True, postData={'data': response})
|
||||
response = ''
|
||||
|
||||
comm_inst.decrementThreadCount('handle_daemon_commands')
|
|
@ -1,10 +1,15 @@
|
|||
'''
|
||||
"""
|
||||
Onionr - Private P2P Communication
|
||||
|
||||
Determine if our node is able to use Tor based on the status of a communicator instance
|
||||
Determine if our node is able to use Tor based
|
||||
on the status of a communicator instance
|
||||
and the result of pinging onion http servers
|
||||
'''
|
||||
'''
|
||||
"""
|
||||
import logger
|
||||
from utils import netutils
|
||||
from onionrutils import localcommand, epoch
|
||||
from . import restarttor
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
|
@ -17,14 +22,12 @@
|
|||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
import logger
|
||||
from utils import netutils
|
||||
from onionrutils import localcommand, epoch
|
||||
from . import restarttor
|
||||
"""
|
||||
|
||||
|
||||
def net_check(comm_inst):
|
||||
'''Check if we are connected to the internet
|
||||
or not when we can't connect to any peers'''
|
||||
"""Check if we are connected to the internet
|
||||
or not when we can't connect to any peers"""
|
||||
# for detecting if we have received incoming connections recently
|
||||
rec = False
|
||||
if len(comm_inst.onlinePeers) == 0:
|
||||
|
@ -46,4 +49,4 @@ def net_check(comm_inst):
|
|||
comm_inst.isOnline = False
|
||||
else:
|
||||
comm_inst.isOnline = True
|
||||
comm_inst.decrementThreadCount('net_check')
|
||||
comm_inst.decrementThreadCount('net_check')
|
||||
|
|
|
@ -38,6 +38,7 @@ def block_mixer(upload_list: List[onionrtypes.BlockHash],
|
|||
to the said block list
|
||||
"""
|
||||
bl = onionrblockapi.Block(block_to_mix)
|
||||
|
||||
if time.time() - bl.claimedTime > onionrvalues.BLOCK_POOL_MAX_AGE:
|
||||
raise ValueError
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue