mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-17 13:07:32 +02:00
Simplify peer client address parameter (#918)
This commit is contained in:
parent
4821fa737b
commit
16f23cd13b
2 changed files with 3 additions and 11 deletions
|
|
@ -2,8 +2,6 @@ import logging
|
|||
import socket
|
||||
import threading
|
||||
|
||||
import squeak.params
|
||||
|
||||
|
||||
MIN_PEERS = 5
|
||||
MAX_PEERS = 10
|
||||
|
|
@ -17,15 +15,10 @@ class PeerClient(object):
|
|||
"""Creates outgoing connections to other peers in the network.
|
||||
"""
|
||||
|
||||
def __init__(self, port=None):
|
||||
self.ip = socket.gethostbyname('localhost')
|
||||
self.port = port or squeak.params.params.DEFAULT_PORT
|
||||
|
||||
def start(self, peer_handler):
|
||||
self.peer_handler = peer_handler
|
||||
|
||||
def make_connection(self, ip, port):
|
||||
address = (ip, port)
|
||||
def make_connection(self, address):
|
||||
logger.debug('Making connection to {}'.format(address))
|
||||
logger.info('Making connection to {}'.format(address))
|
||||
try:
|
||||
|
|
@ -42,9 +35,8 @@ class PeerClient(object):
|
|||
"""Connect to new address."""
|
||||
logger.debug('Connecting to peer with address {}'.format(address))
|
||||
logger.info('Connecting to peer with address {}'.format(address))
|
||||
hostname, port = address
|
||||
threading.Thread(
|
||||
target=self.make_connection,
|
||||
args=(hostname, port),
|
||||
args=(address,),
|
||||
name="peer_client_connection_thread",
|
||||
).start()
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class SqueakNode:
|
|||
|
||||
self.connection_manager = ConnectionManager()
|
||||
self.peer_server = PeerServer(self.config.server.rpc_port)
|
||||
self.peer_client = PeerClient(self.config.server.rpc_port)
|
||||
self.peer_client = PeerClient()
|
||||
|
||||
squeak_controller = SqueakController(
|
||||
squeak_db,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue