def get(self, guid, maxvalues=16, Kp=None, timeout=5): """Get the values for the given guid. The return is an array of tuples (value, nonce, Kp, expires)""" if _debug: print "get(guid=%r, maxvalues=%r, Kp=%r, timeout=%r)" % (guid, maxvalues, Kp, timeout) if self.isSuperNode: result = yield dht.get(self.net, guid, maxvalues=maxvalues, Kp=Kp, timeout=timeout) else: result = yield self.client.get(guid, maxvalues=maxvalues, Kp=Kp, timeout=timeout) raise StopIteration(result)
def requesthandler(msg): p = msg.payload; response = None if self.server: # only if a server if p.name=='Put:Request': result = yield dht.put(net, p.dest, p.value, p.nonce, p.expires, p.Ks, p.put) response = Message(name='Put:Response', seq=p.seq, result=result) elif p.name=='Get:Request': result = yield dht.get(net, p.dest, p.maxvalues, p.Kp) response = Message(name='Get:Response', seq=p.seq, guid=p.guid, vals=result) if response: yield self.net.send(Message(name='Proxy:Response', src=net.node, payload=response), node=msg.src, timeout=5)
def get(self, guid, maxvalues=16, Kp=None, timeout=5): '''Get the values for the given guid. The return is an array of tuples (value, nonce, Kp, expires)''' if _debug: print 'get(guid=%r, maxvalues=%r, Kp=%r, timeout=%r)' % ( guid, maxvalues, Kp, timeout) if self.isSuperNode: result = yield dht.get(self.net, guid, maxvalues=maxvalues, Kp=Kp, timeout=timeout) else: result = yield self.client.get(guid, maxvalues=maxvalues, Kp=Kp, timeout=timeout) raise StopIteration(result)
def requesthandler(msg): p = msg.payload response = None if self.server: # only if a server if p.name == 'Put:Request': result = yield dht.put(net, p.dest, p.value, p.nonce, p.expires, p.Ks, p.put) response = Message(name='Put:Response', seq=p.seq, result=result) elif p.name == 'Get:Request': result = yield dht.get(net, p.dest, p.maxvalues, p.Kp) response = Message(name='Get:Response', seq=p.seq, guid=p.guid, vals=result) if response: yield self.net.send(Message(name='Proxy:Response', src=net.node, payload=response), node=msg.src, timeout=5)