Exemplo n.º 1
0
 def krpc_find_node(self, target, id, _krpc_sender):
     nodes = self.table.findNodes(target, invalid=False)
     nodes = map(lambda node: node.senderDict(), nodes)
     sender = {'id' : id}
     sender['host'] = _krpc_sender[0]
     sender['port'] = _krpc_sender[1]        
     n = self.Node().initWithDict(sender)
     self.insertNode(n, contacted=0)
     return {"nodes" : packNodes(nodes), "id" : self.node.id}
Exemplo n.º 2
0
 def krpc_find_node(self, target, id, _krpc_sender):
     nodes = self.table.findNodes(target, invalid=False)
     nodes = map(lambda node: node.senderDict(), nodes)
     sender = {'id': id}
     sender['host'] = _krpc_sender[0]
     sender['port'] = _krpc_sender[1]
     n = self.Node().initWithDict(sender)
     self.insertNode(n, contacted=0)
     return {"nodes": packNodes(nodes), "id": self.node.id}
Exemplo n.º 3
0
 def krpc_find_value(self, key, id, _krpc_sender):
     sender = {'id' : id}
     sender['host'] = _krpc_sender[0]
     sender['port'] = _krpc_sender[1]        
     n = self.Node().initWithDict(sender)
     self.insertNode(n, contacted=0)
 
     l = self.retrieveValues(key)
     if len(l) > 0:
         return {'values' : l, "id": self.node.id}
     else:
         nodes = self.table.findNodes(key, invalid=False)
         nodes = map(lambda node: node.senderDict(), nodes)
         return {'nodes' : packNodes(nodes), "id": self.node.id}
Exemplo n.º 4
0
    def krpc_find_value(self, key, id, _krpc_sender):
        sender = {'id': id}
        sender['host'] = _krpc_sender[0]
        sender['port'] = _krpc_sender[1]
        n = self.Node().initWithDict(sender)
        self.insertNode(n, contacted=0)

        l = self.retrieveValues(key)
        if len(l) > 0:
            return {'values': l, "id": self.node.id}
        else:
            nodes = self.table.findNodes(key, invalid=False)
            nodes = map(lambda node: node.senderDict(), nodes)
            return {'nodes': packNodes(nodes), "id": self.node.id}