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)
This commit is contained in:
parent
533e2dd99b
commit
9abb4e7f3c
|
@ -946,8 +946,9 @@ class singleWorker(threading.Thread):
|
||||||
return shared.CreatePacket('msg', payload)
|
return shared.CreatePacket('msg', payload)
|
||||||
|
|
||||||
def prioritizeTarget(self, target, 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
|
#large inventories and twice the inventory average for small inventories
|
||||||
if ( target > (2 ** 64)/(len(payload)*shared.averageNonceTrialsPerByteActual)):
|
ptarget = (1+(2**10)/((2**10)+shared.countNonceTrialsPerByteActual))*(2 ** 64)/(len(payload)*shared.averageNonceTrialsPerByteActual)
|
||||||
target = (1+1/shared.countNonceTrialsPerByteActual)*(2 ** 64)/(len(payload)*shared.averageNonceTrialsPerByteActual)
|
if ( target > ptarget):
|
||||||
|
target = ptarget
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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.
|
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
|
averageNonceTrialsPerByteActual = (networkDefaultPayloadLengthExtraBytes * networkDefaultProofOfWorkNonceTrialsPerByte)/50
|
||||||
|
#count of bytes of inventory (corresponding to average)
|
||||||
countNonceTrialsPerByteActual = 1
|
countNonceTrialsPerByteActual = 1
|
||||||
|
|
||||||
# Remember here the RPC port read from namecoin.conf so we can restore to
|
# 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[
|
POW, = unpack('>Q', hashlib.sha512(hashlib.sha512(data[
|
||||||
:8] + hashlib.sha512(data[8:]).digest()).digest()).digest()[0:8]) #calculate POW
|
:8] + hashlib.sha512(data[8:]).digest()).digest()).digest()[0:8]) #calculate POW
|
||||||
nonceTrialsPerByteActual = (2 ** 64)/(POW*len(data)) #calculate nonceTrialsPerByteActual
|
nonceTrialsPerByteActual = (2 ** 64)/(POW*len(data)) #calculate nonceTrialsPerByteActual
|
||||||
shared.countNonceTrialsPerByteActual += 1 #update count for average
|
shared.countNonceTrialsPerByteActual += len(data) #update byte count for byte average
|
||||||
shared.averageNonceTrialsPerByteActual += (nonceTrialsPerByteActual-shared.averageNonceTrialsPerByteActual)/shared.countNonceTrialsPerByteActual #update inventory average of nonceTrialsPerByteActual
|
shared.averageNonceTrialsPerByteActual += len(data)*(nonceTrialsPerByteActual-shared.averageNonceTrialsPerByteActual)/shared.countNonceTrialsPerByteActual #update inventory byte average of nonceTrialsPerByteActual
|
||||||
|
|
||||||
helper_startup.loadConfig()
|
helper_startup.loadConfig()
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
|
Reference in New Issue
Block a user