-arithmetic.py-
Defines isqrt function to calculate integer square roots of large integers.
-shared.py-
Defines averageNonceTrialsPerByteActual, countNonceTrialsPerByteActual, and the addInventory function (to calculate these values and add objects to inventory). Code updated to call addInventory when adding objects to inventory.
-helper_startup.py-
Adds 'averagenoncetrialsperbyteactual' and 'countnoncetrialsperbyteactual' to newly generated keys.dat files.
-class_sqlThread.py-
Reads 'averagenoncetrialsperbyteactual' and 'countnoncetrialsperbyteactual' from keys.dat (or adds them if they don't exist) and resets 'countnoncetrialsperbyteactual' to its square root (with arithmetic.isqrt) when vacuuming messages.dat.
-class_singleCleaner.py-
Writes 'averagenoncetrialsperbyteactual' and 'countnoncetrialsperbyteactual' to disk when the sql database is written to disk.
-class_singleWorker.py-
Defines prioritizeTarget function (to calculate POW targets with a minimum of averageNonceTrialsPerByteActual, for large inventories, and averageNonceTrialsPerByteActual/2, for small inventories). Code updated to call shared.addInventory when adding objects to inventory and to call prioritizeTarget as the last step when calculating targets.
-class_receiveDataThread-
Sorts outgoing inventory by decreasing nonceTrialsPerByteActual (ie increasing proof strength).
Warning: "Max acceptable difficulty" settings are not implemented as method for limiting the POW specified by the new parameter. We will not be implementing it, but will instead focus on porting the spam fix to the upcoming V3 protocol.
Use locale endoding else this generate error in GU : as default time format can have non ascii char on non english locale, but using ascii in locale can generate UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 :
In PyBitmessage/src/bitmessageqt/__init__.py"
l10n.formatTimestamp())
In PyBitmessage/src/l10n.py", line 81, in formatTimestamp
return unicode(timestring, encoding)
Demote payloadLength from class instance variable to processData local variable as no other function was using it
Improve processData:
-Utilise shared.Header
-Use a memoryview to reduce memory overhead
-Clean up variables before a recursive call
-Strip null bytes from command
Refactor sendData
Various functions:
-Use shared.CreatePacket to generate packets
Fix typo in _checkIPv4Address
Refactored ackDataHasAVaildHeader:
-shared.Header is used as necessary
-avoided slicing wherever possible
-remove trailing null characters when comparing command strings
-don't calculate the checksum of a large payload
Added global variable Header - a compiled Struct to pack/unpack headers so as to avoid repeatedly compiling the same format string
Add a new method CreatePacket to simply and efficiently construct a packet that is ready to be sent
Modify assembleVersionMessage to use CreatePacket