Lazy create peerhashfield objects

This commit is contained in:
shortcutme 2016-09-07 17:41:33 +02:00
parent 7572f8c98b
commit d5651f1df3

View file

@ -29,7 +29,6 @@ class Peer(object):
self.connection = None
self.connection_server = connection_server
self.hashfield = PeerHashfield() # Got optional files hash_id
self.time_hashfield = None # Last time peer's hashfiled downloaded
self.time_my_hashfield_sent = None # Last time my hashfield sent to peer
self.time_found = time.time() # Time of last found in the torrent tracker
@ -43,6 +42,14 @@ class Peer(object):
self.download_bytes = 0 # Bytes downloaded
self.download_time = 0 # Time spent to download
def __getattr__(self, key):
self.site.log.debug("PeerHashfield %s" % (self.key))
if key == "hashfield":
self.hashfield = PeerHashfield()
return self.hashfield
else:
return getattr(self, key)
def log(self, text):
if not config.verbose:
return # Only log if we are in debug mode