Removed difficulty adjuster from pow

Fixed board popularity cache
This commit is contained in:
Kevin Froman 2020-09-19 03:08:42 +00:00
parent 5b3d76067a
commit 646a7c0b80
6 changed files with 12 additions and 15 deletions

View file

@ -23,7 +23,7 @@ import filepaths
DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA"
PASSWORD_LENGTH = 25
ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net'
ONIONR_VERSION = '5.1.0'
ONIONR_VERSION = '5.2.0'
ONIONR_VERSION_CODENAME = 'Genesis'
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION)
API_VERSION = '3' # increments of 1; only change when something fundamental about how the API works changes. This way other nodes know how to communicate without learning too much information about you.

View file

@ -7,7 +7,7 @@ import nacl.encoding, nacl.hash, nacl.utils
import config
import logger
from onionrblocks import onionrblockapi, storagecounter
from onionrblocks import onionrblockapi
from onionrutils import bytesconverter
from onionrcrypto import hashers
@ -28,16 +28,6 @@ from .blocknoncestart import BLOCK_NONCE_START_INT
"""
config.reload()
storage_counter = storagecounter.StorageCounter()
def getDifficultyModifier():
"""returns the difficulty modifier for block storage based
on a variety of factors, currently only disk use.
"""
percentUse = storage_counter.get_percent()
difficultyIncrease = math.floor(4 * percentUse) # difficulty increase is a step function
return difficultyIncrease
def getDifficultyForNewBlock(data):
"""
@ -49,16 +39,18 @@ def getDifficultyForNewBlock(data):
dataSizeInBytes = len(bytesconverter.str_to_bytes(data))
minDifficulty = config.get('general.minimum_send_pow', 4)
totalDifficulty = max(minDifficulty, math.floor(dataSizeInBytes / 1000000.0)) + getDifficultyModifier()
totalDifficulty = max(minDifficulty, math.floor(dataSizeInBytes / 1000000.0))
return totalDifficulty
def getHashDifficulty(h: str):
"""
Return the amount of leading zeroes in a hex hash string (hexHash)
"""
return len(h) - len(h.lstrip('0'))
def hashMeetsDifficulty(hexHash):
"""
Return bool for a hash string to see if it meets pow difficulty defined in config