From 9abb4e7f3c57de3db282eb977c5797eae10a8de7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 30 Sep 2014 16:54:40 +0000 Subject: [PATCH] Update: -changed count and average to be over bytes of inventory objects (instead of number of inventory objects) -fixed typo and tweaked equation in class_singleWorker.prioritizeTarget() to gradually transition to "large inventory mode" after counting about 10 gigabytes of inventory (since last vacuuming the sql database) --- src/class_singleWorker.py | 7 ++++--- src/shared.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index a9b66c0a..c9e4a408 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -946,8 +946,9 @@ class singleWorker(threading.Thread): return shared.CreatePacket('msg', payload) def prioritizeTarget(self, target, payload): - #set target to the inventory average of length adjusted targets for + #set target to at most the inventory average of length adjusted targets for #large inventories and twice the inventory average for small inventories - if ( target > (2 ** 64)/(len(payload)*shared.averageNonceTrialsPerByteActual)): - target = (1+1/shared.countNonceTrialsPerByteActual)*(2 ** 64)/(len(payload)*shared.averageNonceTrialsPerByteActual) + ptarget = (1+(2**10)/((2**10)+shared.countNonceTrialsPerByteActual))*(2 ** 64)/(len(payload)*shared.averageNonceTrialsPerByteActual) + if ( target > ptarget): + target = ptarget diff --git a/src/shared.py b/src/shared.py index b6c1a4e6..6f0c1c6f 100644 --- a/src/shared.py +++ b/src/shared.py @@ -85,8 +85,9 @@ streamsInWhichIAmParticipating = {} networkDefaultProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work. networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target. -#inventory average (and count) of nonce trials per byte of actual payload (excluding extra bytes) +#average over bytes of inventory of nonce trials per byte of actual payload (excluding extra bytes) averageNonceTrialsPerByteActual = (networkDefaultPayloadLengthExtraBytes * networkDefaultProofOfWorkNonceTrialsPerByte)/50 +#count of bytes of inventory (corresponding to average) countNonceTrialsPerByteActual = 1 # Remember here the RPC port read from namecoin.conf so we can restore to @@ -798,8 +799,8 @@ def addInventory(inventoryHash, objectType, streamNumber, data, embeddedTime, ta POW, = unpack('>Q', hashlib.sha512(hashlib.sha512(data[ :8] + hashlib.sha512(data[8:]).digest()).digest()).digest()[0:8]) #calculate POW nonceTrialsPerByteActual = (2 ** 64)/(POW*len(data)) #calculate nonceTrialsPerByteActual - shared.countNonceTrialsPerByteActual += 1 #update count for average - shared.averageNonceTrialsPerByteActual += (nonceTrialsPerByteActual-shared.averageNonceTrialsPerByteActual)/shared.countNonceTrialsPerByteActual #update inventory average of nonceTrialsPerByteActual + shared.countNonceTrialsPerByteActual += len(data) #update byte count for byte average + shared.averageNonceTrialsPerByteActual += len(data)*(nonceTrialsPerByteActual-shared.averageNonceTrialsPerByteActual)/shared.countNonceTrialsPerByteActual #update inventory byte average of nonceTrialsPerByteActual helper_startup.loadConfig() from debug import logger