]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_p2p_Khashmir/node.py
More strict use of errbacks when using deferreds.
[quix0rs-apt-p2p.git] / apt_p2p_Khashmir / node.py
index 49b8fe75a06923379d5bfecad8d86f083262a5aa..c1300c74a08ee2f9e4538d531cd442ebd8fe3688 100644 (file)
@@ -105,6 +105,17 @@ class Node:
     def __repr__(self):
         return `(self.id, self.host, self.port)`
     
+    def __copy__(self):
+        """Create a shallow copy of the node, resetting some values."""
+        cp = self.__class__(self.id, self.host, self.port)
+        cp.fails = self.fails
+        cp.lastSeen = self.lastSeen
+        if getattr(self, 'table', None) is not None:
+            cp.table = self.table
+        if getattr(self, 'conn', None) is not None:
+            cp.conn = self.conn
+        return cp
+    
     #{ Comparators to bisect/index a list of nodes with either a node or a long
     def __lt__(self, a):
         if type(a) == InstanceType: