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

@ -15,5 +15,4 @@
* add BCC support to mail
* prevent local insertion success of duplicate block content
* truncate last N blocks when sharing list

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

View File

@ -108,6 +108,7 @@ def remove_from_cache(board, name):
@flask_blueprint.route('/circles/getpopular/<count>')
def get_popular(count):
read_only_cache.refresh()
boards = json.loads(read_only_cache.get_raw_json())
for board in boards:
boards[board] = len(boards[board])

View File

@ -94,6 +94,11 @@ function appendMessages(msg, blockHash, beforeHash, channel) {
if (typeof msg['meta']['signer'] != 'undefined' && msg['meta']['signer'].length > 0){
div[3].textContent = msg['meta']['signer'].substr(0, 5)
setHumanReadableIDOnPost(div[3], msg['meta']['signer'])
div[3].onclick = function(){
navigator.clipboard.writeText(div[3].title).then(function() {
PNotify.notice("Copied poster identity to clipboard")
})
}
div[3].title = msg['meta']['signer']
userIcon(msg['meta']['signer']).then(function(data){
identicon[0].src = "data:image/svg+xml;base64," + data

View File

@ -125,7 +125,7 @@
</header>
<div class="card-content">
<div class="content">
<div class="field">
<div class="field" data-tooltip="Site public key or hash (not onion)">
<label class="label">Open Site</label>
<div class="field has-addons">
<p class="control is-expanded">