Пример #1
0
        def _getValueForKey(nodes, key=key, response=callback, self=self, searchlocal=searchlocal):
            """Use the found nodes to send requests for values to."""
            # Get any local values
            if searchlocal:
                l = self.store.retrieveValues(key)
                if len(l) > 0:
                    node = copy(self.node)
                    node.updateNumValues(len(l))
                    nodes = nodes + [node]

            state = GetValue(self, key, self.config['RETRIEVE_VALUES'], response, self.config, self.stats)
            reactor.callLater(0, state.goWithNodes, nodes)
Пример #2
0
    def valueForKey(self, key, callback, searchlocal=1):
        """ returns the values found for key in global table
            callback will be called with a list of values for each peer that returns unique values
            final callback will be an empty list - probably should change to 'more coming' arg
        """
        nodes = self.table.findNodes(key)

        # get locals
        if searchlocal:
            l = self.retrieveValues(key)
            if len(l) > 0:
                self.rawserver.external_add_task(0, callback, l)
        else:
            l = []

        # create our search state
        state = GetValue(self, key, callback, self.rawserver.add_task)
        self.rawserver.external_add_task(0, state.goWithNodes, nodes, l)