def find(self, ipp): ''' Tries to find the end for the given ipptup in our beckets. If it isn't there, it adds a new one. ''' if self.switch.ipp: h = hash.hexhash(ipp) b = self.bucket_for(ipp) if h in b: e = b[h] else: e = End(ipp) self.add(e) else: e = End(ipp) return e
def add(self, e): ''' Adds the given end to our buckets iff an end isn't already there. ''' if e.ipp != self.switch.ipp and not hash.hexhash(e.ipp) in self.bucket_for(e.ipp): self.bucket_for(e.ipp)[hash.hexhash(e.ipp)] = e
def send_bootstrap_telex(switch): ''' Sends an arbitrary bootstrap telex. Should be relocated, I believe. ''' t = Telex(other_dict={'+end':hash.hexhash('1.2.3.4:5555')}) switch.send(t, switch.ends.find(switch.seed_ipp))