예제 #1
0
    def _setup_download(self):
        self._started = time.time()
        self._status.set_status("Retrieving Shares")

        # how many shares do we need?
        (seqnum, root_hash, IV, segsize, datalength, k, N, prefix, offsets_tuple) = self.verinfo

        # first, which servers can we use?
        versionmap = self.servermap.make_versionmap()
        shares = versionmap[self.verinfo]
        # this sharemap is consumed as we decide to send requests
        self.remaining_sharemap = DictOfSets()
        for (shnum, server, timestamp) in shares:
            self.remaining_sharemap.add(shnum, server)
            # If the servermap update fetched anything, it fetched at least 1
            # KiB, so we ask for that much.
            # TODO: Change the cache methods to allow us to fetch all of the
            # data that they have, then change this method to do that.
            any_cache = self._node._read_from_cache(self.verinfo, shnum, 0, 1000)
            reader = MDMFSlotReadProxy(server.get_rref(), self._storage_index, shnum, any_cache)
            reader.server = server
            self.readers[shnum] = reader
        assert len(self.remaining_sharemap) >= k

        self.shares = {}  # maps shnum to validated blocks
        self._active_readers = []  # list of active readers for this dl.
        self._block_hash_trees = {}  # shnum => hashtree

        # We need one share hash tree for the entire file; its leaves
        # are the roots of the block hash trees for the shares that
        # comprise it, and its root is in the verinfo.
        self.share_hash_tree = hashtree.IncompleteHashTree(N)
        self.share_hash_tree.set_hashes({0: root_hash})
예제 #2
0
    def _setup_download(self):
        self._started = time.time()
        self._status.set_status("Retrieving Shares")

        # how many shares do we need?
        (seqnum,
         root_hash,
         IV,
         segsize,
         datalength,
         k,
         N,
         prefix,
         offsets_tuple) = self.verinfo

        # first, which servers can we use?
        versionmap = self.servermap.make_versionmap()
        shares = versionmap[self.verinfo]
        # this sharemap is consumed as we decide to send requests
        self.remaining_sharemap = DictOfSets()
        for (shnum, server, timestamp) in shares:
            self.remaining_sharemap.add(shnum, server)
            # Reuse the SlotReader from the servermap.
            key = (self.verinfo, server.get_serverid(),
                   self._storage_index, shnum)
            if key in self.servermap.proxies:
                reader = self.servermap.proxies[key]
            else:
                reader = MDMFSlotReadProxy(server.get_rref(),
                                           self._storage_index, shnum, None)
            reader.server = server
            self.readers[shnum] = reader

        if len(self.remaining_sharemap) < k:
            self._raise_notenoughshareserror()

        self.shares = {} # maps shnum to validated blocks
        self._active_readers = [] # list of active readers for this dl.
        self._block_hash_trees = {} # shnum => hashtree

        for i in xrange(self._total_shares):
            # So we don't have to do this later.
            self._block_hash_trees[i] = hashtree.IncompleteHashTree(self._num_segments)

        # We need one share hash tree for the entire file; its leaves
        # are the roots of the block hash trees for the shares that
        # comprise it, and its root is in the verinfo.
        self.share_hash_tree = hashtree.IncompleteHashTree(N)
        self.share_hash_tree.set_hashes({0: root_hash})
예제 #3
0
파일: retrieve.py 프로젝트: trel/tahoe-lafs
    def _setup_download(self):
        self._started = time.time()
        self._status.set_status("Retrieving Shares")

        # how many shares do we need?
        (seqnum, root_hash, IV, segsize, datalength, k, N, prefix,
         offsets_tuple) = self.verinfo

        # first, which servers can we use?
        versionmap = self.servermap.make_versionmap()
        shares = versionmap[self.verinfo]
        # this sharemap is consumed as we decide to send requests
        self.remaining_sharemap = DictOfSets()
        for (shnum, server, timestamp) in shares:
            self.remaining_sharemap.add(shnum, server)
            # If the servermap update fetched anything, it fetched at least 1
            # KiB, so we ask for that much.
            # TODO: Change the cache methods to allow us to fetch all of the
            # data that they have, then change this method to do that.
            any_cache = self._node._read_from_cache(self.verinfo, shnum, 0,
                                                    1000)
            reader = MDMFSlotReadProxy(server.get_rref(), self._storage_index,
                                       shnum, any_cache)
            reader.server = server
            self.readers[shnum] = reader
        assert len(self.remaining_sharemap) >= k

        self.shares = {}  # maps shnum to validated blocks
        self._active_readers = []  # list of active readers for this dl.
        self._block_hash_trees = {}  # shnum => hashtree

        # We need one share hash tree for the entire file; its leaves
        # are the roots of the block hash trees for the shares that
        # comprise it, and its root is in the verinfo.
        self.share_hash_tree = hashtree.IncompleteHashTree(N)
        self.share_hash_tree.set_hashes({0: root_hash})