def put(self, guid, value, nonce, expires, timeout=30): '''put a (guid, value) pair with the given nonce. The value is signed by this socket's private key. It uses either dht.put to put the data using this DHT node or client's put method to send the request to a DHT node.''' if _debug: print 'put(guid=%r, value=%r, nonce=%r, expires=%r, timeout=%r)' % ( guid, value, nonce, expires, timeout) Ks = hasattr(self.net, 'Ks') and self.net.Ks or None if self.isSuperNode: result = yield dht.put(self.net, guid, value, nonce, expires, Ks=Ks, timeout=timeout, retry=7) else: result = yield self.client.put(guid, value, nonce, expires, Ks=Ks, put=True, timeout=timeout) raise StopIteration(result)
def put(self, guid, value, nonce, expires, timeout=30): '''put a (guid, value) pair with the given nonce. The value is signed by this socket's private key. It uses either dht.put to put the data using this DHT node or client's put method to send the request to a DHT node.''' if _debug: print 'put(guid=%r, value=%r, nonce=%r, expires=%r, timeout=%r)'%(guid, value, nonce, expires, timeout) Ks = hasattr(self.net, 'Ks') and self.net.Ks or None if self.isSuperNode: result = yield dht.put(self.net, guid, value, nonce, expires, Ks=Ks, timeout=timeout, retry=7) else: result = yield self.client.put(guid, value, nonce, expires, Ks=Ks, put=True, 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 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)