def start(self, net=None, servers=None): """Start the p2p node as ordinary node. Create a network object if none.""" if self.net is None: self.net = net or Network(Ks=crypto.generateRSA()[0], cert=None, port=self.port) self.net.start() # convert from serevrs ip:port list to Node list if servers: servers = [ Node(ip=ip, port=port, type=socket.SOCK_DGRAM, guid=H(ip + ":" + str(port))) for ip, port in servers ] if _debug: print "using servers=", servers self.client = Client(self.net, server=self.server).start(servers) if self.server: if self.router is None: self.router = dht.Router(self.net).start() if self.storage is None: self.storage = dht.Storage(self.net, self.router).start() if not self.router.initialized: self.router.initialized = True if not self._gens: for gen in [self.handler()]: multitask.add(gen) self._gens.append(gen) return self
def start(self, net=None, servers=None): '''Start the p2p node as ordinary node. Create a network object if none.''' if self.net is None: self.net = net or Network( Ks=crypto.generateRSA()[0], cert=None, port=self.port) self.net.start() # convert from serevrs ip:port list to Node list if servers: servers = [ Node(ip=ip, port=port, type=socket.SOCK_DGRAM, guid=H(ip + ':' + str(port))) for ip, port in servers ] if _debug: print 'using servers=', servers self.client = Client(self.net, server=self.server).start(servers) if self.server: if self.router is None: self.router = dht.Router(self.net).start() if self.storage is None: self.storage = dht.Storage(self.net, self.router).start() if not self.router.initialized: self.router.initialized = True if not self._gens: for gen in [self.handler()]: multitask.add(gen) self._gens.append(gen) return self
def start(self, net=None): '''Start the p2p node as ordinary node. Create a network object if none.''' if self.net is None: self.net = net or Network(Ks=crypto.generateRSA()[0], cert=None) self.net.start() self.client = Client(self.net, server=self.server).start() if self.server: if self.router is None: self.router = dht.Router(self.net).start() if self.storage is None: self.storage = dht.Storage(self.net, self.router).start() if not self.router.initialized: self.router.initialized = True if not self._gens: for gen in [self.handler()]: multitask.add(gen); self._gens.append(gen) return self
def start(self, net=None): '''Start the p2p node as ordinary node. Create a network object if none.''' if self.net is None: self.net = net or Network(Ks=crypto.generateRSA()[0], cert=None) self.net.start() self.client = Client(self.net, server=self.server).start() if self.server: if self.router is None: self.router = dht.Router(self.net).start() if self.storage is None: self.storage = dht.Storage(self.net, self.router).start() if not self.router.initialized: self.router.initialized = True if not self._gens: for gen in [self.handler()]: multitask.add(gen) self._gens.append(gen) return self