+Evaluate and fix some errors in the ktable khashmir module.
+
+The KTable implementation has some possible errors in it. insertNode
+does not remove the original and use the new node when updating a node
+already in the table, as claimed by the comments. justSeenNode doesn't
+verify that the found node is the node that was being looked for, nor
+does it move the node to the end of the list of nodes (since they are
+supposed to be sorted by their lastSeen time) or update the bucket's
+last touched time.nodeFailed also doesn't verify the found node is the
+right node.
+
+
Consider what happens when we are the closest node.
In some of the actions it is unclear what happens when we are one of the
providing a later piece. This doesn't work if the differing piece is the
first piece, in which case it is downloaded from a 3rd peer, with
consensus revealing the misbehaving peer.
+
+
+Consider adding peer characteristics to the DHT.
+
+Bad peers could be indicated in the DHT by adding a new value that is
+the NOT of their ID (so they are guaranteed not to store it) indicating
+information about the peer. This could be bad votes on the peer, as
+otherwise a peer could add good info about itself.
+
+
+Consider adding pieces to the DHT instead of files.
+
+Instead of adding file hashes to the DHT, only piece hashes could be
+added. This would allow a peer to upload to other peers while it is
+still downloading the rest of the file. It is not clear that this is
+needed, since peer's will not be uploading and downloading ery much of
+the time.
def __del__(self):
self.cleanup()
- self.packages.close()
def addRelease(self, cache_path, file_path):
"""Add a Release file's info to the list of index files.
def cleanup(self):
"""Cleanup and close any loaded caches."""
self.unload()
+ if self.unload_later and self.unload_later.active():
+ self.unload_later.cancel()
self.packages.close()
def findHash(self, path):
d.errback(MirrorError("Site Not Found"))
return d
+ def cleanup(self):
+ for site in self.apt_caches.keys():
+ for baseDir in self.apt_caches[site].keys():
+ self.apt_caches[site][baseDir].cleanup()
+ del self.apt_caches[site][baseDir]
+ del self.apt_caches[site]
+
class TestMirrorManager(unittest.TestCase):
"""Unit tests for the mirror manager."""
for p in self.pending_calls:
if p.active():
p.cancel()
+ self.client.cleanup()
self.client = None
\ No newline at end of file
else:
# Add the new hash to the database
c = self.conn.cursor()
- c.execute("INSERT OR REPLACE INTO hashes (hash, pieces, piecehash, refreshed) VALUES (?, ?, ?)",
+ c.execute("INSERT OR REPLACE INTO hashes (hash, pieces, piecehash, refreshed) VALUES (?, ?, ?, ?)",
(khash(hash), khash(pieces), khash(piecehash), datetime.now()))
self.conn.commit()
new_hash = True