Lazy create peerhashfield objects
This commit is contained in:
parent
7572f8c98b
commit
d5651f1df3
1 changed files with 8 additions and 1 deletions
|
@ -29,7 +29,6 @@ class Peer(object):
|
||||||
|
|
||||||
self.connection = None
|
self.connection = None
|
||||||
self.connection_server = connection_server
|
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_hashfield = None # Last time peer's hashfiled downloaded
|
||||||
self.time_my_hashfield_sent = None # Last time my hashfield sent to peer
|
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
|
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_bytes = 0 # Bytes downloaded
|
||||||
self.download_time = 0 # Time spent to download
|
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):
|
def log(self, text):
|
||||||
if not config.verbose:
|
if not config.verbose:
|
||||||
return # Only log if we are in debug mode
|
return # Only log if we are in debug mode
|
||||||
|
|
Loading…
Reference in a new issue