def __init__(self, peermanager, connection, remote_pubkey=None): super(Peer, self).__init__() self.is_stopped = False self.hello_received = False self.peermanager = peermanager self.connection = connection self.config = peermanager.config self.protocols = OrderedDict() log.debug('peer init', peer=self) # create multiplexed encrypted session privkey = self.config['node']['privkey_hex'].decode('hex') hello_packet = P2PProtocol.get_hello_packet(self) self.mux = MultiplexedSession(privkey, hello_packet, remote_pubkey=remote_pubkey) self.remote_pubkey = remote_pubkey # register p2p protocol assert issubclass(self.peermanager.wire_protocol, P2PProtocol) self.connect_service(self.peermanager) # assure, we don't get messages while replies are not read self.safe_to_read = gevent.event.Event() self.safe_to_read.set() # Stop peer if hello not received in self.dumb_remote_timeout seconds gevent.spawn_later(self.dumb_remote_timeout, self.check_if_dumb_remote)
def __init__(self, peermanager, connection, remote_pubkey=None): # FIXME node vs remote_pubkey super(Peer, self).__init__() self.is_stopped = False self.peermanager = peermanager self.connection = connection self.config = peermanager.config self.protocols = OrderedDict() log.debug('peer init', peer=self) # create multiplexed encrypted session privkey = self.config['node']['privkey_hex'].decode('hex') hello_packet = P2PProtocol.get_hello_packet(self) self.mux = MultiplexedSession(privkey, hello_packet, token_by_pubkey=dict(), remote_pubkey=remote_pubkey) # register p2p protocol assert issubclass(self.peermanager.wire_protocol, P2PProtocol) self.connect_service(self.peermanager) # assure, we don't get messages while replies are not read self.safe_to_read = gevent.event.Event() self.safe_to_read.set()