logger.info('inv message lists %s objects. Of those %s are new to me. It took %s seconds to figure that out.',numberOfItemsInInv,len(objectsNewToMe),time.time()-startTime)
# To prevent some network analysis, 'leak' the data out
# to our peer after waiting a random amount of time
random.seed()
time.sleep(random.randrange(0,10))
try:
self.sock.sendall(headerData+payload)
self.lastTimeISentData=int(time.time())
@ -142,6 +149,8 @@ class sendDataThread(threading.Thread):
shared.sendDataQueues.remove(self.mailbox)
print'sendDataThread thread (ID:',str(id(self))+') ending now. Was connected to',self.peer
break
else:
print'(within sendinv) payload was empty. Not sending anything'#testing.
elifcommand=='pong':
self.someObjectsOfWhichThisRemoteNodeIsAlreadyAware.clear()# To save memory, let us clear this data structure from time to time. As its function is to help us keep from sending inv messages to peers which sent us the same inv message mere seconds earlier, it will be fine to clear this data structure from time to time.
ifself.lastTimeISentData<(int(time.time())-298):
@ -167,4 +176,4 @@ class sendDataThread(threading.Thread):
withshared.printLock:
print'sendDataThread ID:',id(self),'ignoring command',command,'because the thread is not in stream',deststream
inventorySets={}# key = streamNumer, value = a set which holds the inventory object hashes that we are aware of. This is used whenever we receive an inv message from a peer to check to see what items are new to us. We don't delete things out of it; instead, the singleCleaner thread clears and refills it every couple hours.
#If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them!
networkDefaultProofOfWorkNonceTrialsPerByte=320#The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work.