From 3422ca43ffbf9f339a6d63d2e324d8857415fd8f Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 25 Aug 2020 15:02:13 -0500 Subject: [PATCH] Fixing block syncing quirks --- scripts/disable-dev-config.py | 1 - src/communicatorutils/lookupblocks.py | 4 +--- src/etc/onionrvalues.py | 2 +- src/onionrblocks/insert/main.py | 7 +------ src/onionrutils/validatemetadata.py | 3 ++- static-data/www/shared/main/stats.js | 4 ++-- tests/test_default_config_json.py | 1 - 7 files changed, 7 insertions(+), 15 deletions(-) diff --git a/scripts/disable-dev-config.py b/scripts/disable-dev-config.py index 4b7e34cc..b1dced09 100755 --- a/scripts/disable-dev-config.py +++ b/scripts/disable-dev-config.py @@ -19,7 +19,6 @@ conf['general']['security_level'] = 0 conf['onboarding']['done'] = False conf['general']['minimum_block_pow'] = 5 conf['general']['minimum_send_pow'] = 5 -conf['general']['max_block_age'] = 2678400 conf['log']['file']['remove_on_exit'] = True conf['transports']['lan'] = True conf['transports']['tor'] = True diff --git a/src/communicatorutils/lookupblocks.py b/src/communicatorutils/lookupblocks.py index 26c152c5..f0f7e22c 100755 --- a/src/communicatorutils/lookupblocks.py +++ b/src/communicatorutils/lookupblocks.py @@ -83,9 +83,7 @@ def lookup_blocks_from_communicator(comm_inst): try: lastLookupTime = kv.get('dbTimestamps')[peer] except KeyError: - lastLookupTime = epoch.get_epoch() - \ - config.get("general.max_block_age", - onionrvalues.DEFAULT_EXPIRE) + lastLookupTime = epoch.get_epoch() - onionrvalues.DEFAULT_EXPIRE listLookupCommand += '?date=%s' % (lastLookupTime,) try: newBlocks = peeraction.peer_action( diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py index bc8ba59e..e9958238 100755 --- a/src/etc/onionrvalues.py +++ b/src/etc/onionrvalues.py @@ -26,7 +26,7 @@ ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net' ONIONR_VERSION = '5.0.1' ONIONR_VERSION_CODENAME = 'Genesis' ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION) -API_VERSION = '1' # 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. +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. MIN_PY_VERSION = 7 # min version of 7 so we can take advantage of non-cyclic type hints DEVELOPMENT_MODE = False IS_QUBES = False diff --git a/src/onionrblocks/insert/main.py b/src/onionrblocks/insert/main.py index 81e07e6f..8f590158 100644 --- a/src/onionrblocks/insert/main.py +++ b/src/onionrblocks/insert/main.py @@ -232,12 +232,7 @@ def insert_block(data: Union[str, bytes], header: str = 'txt', if expire is None: coredb.blockmetadb.update_block_info( retData, 'expire', - createTime + - min( - onionrvalues.DEFAULT_EXPIRE, - config.get( - 'general.max_block_age', - onionrvalues.DEFAULT_EXPIRE))) + createTime + onionrvalues.DEFAULT_EXPIRE) else: coredb.blockmetadb.update_block_info(retData, 'expire', expire) diff --git a/src/onionrutils/validatemetadata.py b/src/onionrutils/validatemetadata.py index ec2cb148..3b4f31cf 100644 --- a/src/onionrutils/validatemetadata.py +++ b/src/onionrutils/validatemetadata.py @@ -39,7 +39,7 @@ def validate_metadata(metadata, block_data) -> bool: pass # Validate metadata dict for invalid keys to sizes that are too large - maxAge = config.get("general.max_block_age", onionrvalues.DEFAULT_EXPIRE) + maxAge = onionrvalues.DEFAULT_EXPIRE if type(metadata) is dict: for i in metadata: try: @@ -100,6 +100,7 @@ def validate_metadata(metadata, block_data) -> bool: try: metadata['time'] except KeyError: + logger.warn("Time header not set") return False nonce = bytesconverter.bytes_to_str(onionrcrypto.hashers.sha3_hash(block_data)) diff --git a/static-data/www/shared/main/stats.js b/static-data/www/shared/main/stats.js index 139db077..4cee2d7b 100755 --- a/static-data/www/shared/main/stats.js +++ b/static-data/www/shared/main/stats.js @@ -114,8 +114,8 @@ var getStats = function(){ "token": webpass }}) .then((resp) => resp.text()) - .then(function(totalRec) { - totalRec.innerText = totalRec + .then(function(resp) { + totalRec.innerText = resp }) fetch('/lastconnect', { headers: { diff --git a/tests/test_default_config_json.py b/tests/test_default_config_json.py index ae5ab5a8..fe9f9561 100644 --- a/tests/test_default_config_json.py +++ b/tests/test_default_config_json.py @@ -27,7 +27,6 @@ class OnionrConfig(unittest.TestCase): self.assertEqual(conf['general']['ephemeral_tunnels'], False) self.assertEqual(conf['general']['hide_created_blocks'], True) self.assertEqual(conf['general']['insert_deniable_blocks'], True) - self.assertEqual(conf['general']['max_block_age'], 2678400) self.assertEqual(conf['general']['minimum_block_pow'], 5) self.assertEqual(conf['general']['minimum_send_pow'], 5) self.assertEqual(conf['general']['public_key'], '')