From b4703ec6ce37fda706e5f296ec30038944b9e275 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 10 Jan 2017 21:19:57 +0100 Subject: [PATCH] Make objectHashHolder into a list - was a dict --- src/class_objectHashHolder.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/class_objectHashHolder.py b/src/class_objectHashHolder.py index 30d27ea8..24c2438d 100644 --- a/src/class_objectHashHolder.py +++ b/src/class_objectHashHolder.py @@ -17,11 +17,11 @@ class objectHashHolder(threading.Thread): threading.Thread.__init__(self, name="objectHashHolder") self.shutdown = False self.sendDataThreadMailbox = sendDataThreadMailbox # This queue is used to submit data back to our associated sendDataThread. - self.collectionOfHashLists = {} - self.collectionOfPeerLists = {} - for i in range(self.size): - self.collectionOfHashLists[i] = [] - self.collectionOfPeerLists[i] = [] + self.collectionOfHashLists = [] + self.collectionOfPeerLists = [] + for i in range(objectHashHolder.size): + self.collectionOfHashLists.append([]) + self.collectionOfPeerLists.append([]) def run(self): iterator = 0 @@ -33,11 +33,11 @@ class objectHashHolder(threading.Thread): self.sendDataThreadMailbox.put((0, 'sendaddr', self.collectionOfPeerLists[iterator])) self.collectionOfPeerLists[iterator] = [] iterator += 1 - iterator %= self.size + iterator %= objectHashHolder.size time.sleep(1) def holdHash(self,hash): - self.collectionOfHashLists[random.randrange(0, self.size)].append(hash) + self.collectionOfHashLists[random.randrange(0, objectHashHolder.size)].append(hash) def hasHash(self, hash): if hash in (hashlist for hashlist in self.collectionOfHashLists): @@ -46,7 +46,7 @@ class objectHashHolder(threading.Thread): return False def holdPeer(self,peerDetails): - self.collectionOfPeerLists[random.randrange(0, self.size)].append(peerDetails) + self.collectionOfPeerLists[random.randrange(0, objectHashHolder.size)].append(peerDetails) def hashCount(self): return sum([len(x) for x in self.collectionOfHashLists if type(x) is list])