From 646a7c0b805a841901ee6de9d3f7a0bc8517f51b Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 19 Sep 2020 03:08:42 +0000 Subject: [PATCH] Removed difficulty adjuster from pow Fixed board popularity cache --- docs/TODO.txt | 1 - src/etc/onionrvalues.py | 2 +- src/onionrproofs/__init__.py | 16 ++++------------ static-data/default-plugins/circles/flowapi.py | 1 + static-data/default-plugins/circles/web/board.js | 5 +++++ static-data/www/private/index.html | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index ed49b915..f57c4741 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -15,5 +15,4 @@ * add BCC support to mail -* prevent local insertion success of duplicate block content * truncate last N blocks when sharing list diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py index cf68e376..bfe66c37 100755 --- a/src/etc/onionrvalues.py +++ b/src/etc/onionrvalues.py @@ -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. diff --git a/src/onionrproofs/__init__.py b/src/onionrproofs/__init__.py index a90a7c74..e0f4a956 100755 --- a/src/onionrproofs/__init__.py +++ b/src/onionrproofs/__init__.py @@ -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 diff --git a/static-data/default-plugins/circles/flowapi.py b/static-data/default-plugins/circles/flowapi.py index 8121c079..30668e97 100755 --- a/static-data/default-plugins/circles/flowapi.py +++ b/static-data/default-plugins/circles/flowapi.py @@ -108,6 +108,7 @@ def remove_from_cache(board, name): @flask_blueprint.route('/circles/getpopular/') 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]) diff --git a/static-data/default-plugins/circles/web/board.js b/static-data/default-plugins/circles/web/board.js index 61e10a22..8a2a3be5 100755 --- a/static-data/default-plugins/circles/web/board.js +++ b/static-data/default-plugins/circles/web/board.js @@ -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 diff --git a/static-data/www/private/index.html b/static-data/www/private/index.html index 031c893b..b42057ec 100755 --- a/static-data/www/private/index.html +++ b/static-data/www/private/index.html @@ -125,7 +125,7 @@
-
+