mostly finished refactoring communicator into a module
This commit is contained in:
parent
9bf6c76557
commit
dbd154d450
8 changed files with 73 additions and 91 deletions
|
@ -21,7 +21,7 @@ import time, sys, secrets
|
|||
import onionrexceptions, logger, onionrpeers
|
||||
from utils import networkmerger
|
||||
from onionrutils import stringvalidators, epoch
|
||||
from communicator import peeraction
|
||||
from communicator import peeraction, bootstrappeers
|
||||
|
||||
def connect_new_peer_to_communicator(comm_inst, peer='', useBootstrap=False):
|
||||
config = comm_inst._core.config
|
||||
|
@ -50,7 +50,7 @@ def connect_new_peer_to_communicator(comm_inst, peer='', useBootstrap=False):
|
|||
|
||||
if len(peerList) == 0 or useBootstrap:
|
||||
# Avoid duplicating bootstrap addresses in peerList
|
||||
comm_inst.addBootstrapListToPeerList(peerList)
|
||||
bootstrappeers.add_bootstrap_list_to_peer_list(comm_inst, peerList)
|
||||
|
||||
for address in peerList:
|
||||
if not config.get('tor.v3onions') and len(address) == 62:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
from onionrutils import epoch
|
||||
from communicator import onlinepeers
|
||||
def cooldown_peer(comm_inst):
|
||||
'''Randomly add an online peer to cooldown, so we can connect a new one'''
|
||||
onlinePeerAmount = len(comm_inst.onlinePeers)
|
||||
|
@ -46,7 +47,7 @@ def cooldown_peer(comm_inst):
|
|||
except ValueError:
|
||||
break
|
||||
else:
|
||||
comm_inst.removeOnlinePeer(toCool)
|
||||
onlinepeers.remove_online_peer(comm_inst, toCool)
|
||||
comm_inst.cooldownPeer[toCool] = epoch.get_epoch()
|
||||
|
||||
comm_inst.decrementThreadCount('cooldown_peer')
|
|
@ -35,7 +35,7 @@ def download_blocks_from_communicator(comm_inst):
|
|||
blockPeers = []
|
||||
removeFromQueue = True
|
||||
|
||||
if shoulddownload.should_download(comm_inst, blockHash):
|
||||
if not shoulddownload.should_download(comm_inst, blockHash):
|
||||
continue
|
||||
|
||||
if comm_inst.shutdown or not comm_inst.isOnline or comm_inst._core.storage_counter.isFull():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue