Fixing block syncing quirks

master
Kevin Froman 2020-08-25 15:02:13 -05:00
parent a83351a73c
commit 3422ca43ff
7 changed files with 7 additions and 15 deletions

View File

@ -19,7 +19,6 @@ conf['general']['security_level'] = 0
conf['onboarding']['done'] = False conf['onboarding']['done'] = False
conf['general']['minimum_block_pow'] = 5 conf['general']['minimum_block_pow'] = 5
conf['general']['minimum_send_pow'] = 5 conf['general']['minimum_send_pow'] = 5
conf['general']['max_block_age'] = 2678400
conf['log']['file']['remove_on_exit'] = True conf['log']['file']['remove_on_exit'] = True
conf['transports']['lan'] = True conf['transports']['lan'] = True
conf['transports']['tor'] = True conf['transports']['tor'] = True

View File

@ -83,9 +83,7 @@ def lookup_blocks_from_communicator(comm_inst):
try: try:
lastLookupTime = kv.get('dbTimestamps')[peer] lastLookupTime = kv.get('dbTimestamps')[peer]
except KeyError: except KeyError:
lastLookupTime = epoch.get_epoch() - \ lastLookupTime = epoch.get_epoch() - onionrvalues.DEFAULT_EXPIRE
config.get("general.max_block_age",
onionrvalues.DEFAULT_EXPIRE)
listLookupCommand += '?date=%s' % (lastLookupTime,) listLookupCommand += '?date=%s' % (lastLookupTime,)
try: try:
newBlocks = peeraction.peer_action( newBlocks = peeraction.peer_action(

View File

@ -26,7 +26,7 @@ ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net'
ONIONR_VERSION = '5.0.1' ONIONR_VERSION = '5.0.1'
ONIONR_VERSION_CODENAME = 'Genesis' ONIONR_VERSION_CODENAME = 'Genesis'
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION) 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 MIN_PY_VERSION = 7 # min version of 7 so we can take advantage of non-cyclic type hints
DEVELOPMENT_MODE = False DEVELOPMENT_MODE = False
IS_QUBES = False IS_QUBES = False

View File

@ -232,12 +232,7 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
if expire is None: if expire is None:
coredb.blockmetadb.update_block_info( coredb.blockmetadb.update_block_info(
retData, 'expire', retData, 'expire',
createTime + createTime + onionrvalues.DEFAULT_EXPIRE)
min(
onionrvalues.DEFAULT_EXPIRE,
config.get(
'general.max_block_age',
onionrvalues.DEFAULT_EXPIRE)))
else: else:
coredb.blockmetadb.update_block_info(retData, 'expire', expire) coredb.blockmetadb.update_block_info(retData, 'expire', expire)

View File

@ -39,7 +39,7 @@ def validate_metadata(metadata, block_data) -> bool:
pass pass
# Validate metadata dict for invalid keys to sizes that are too large # 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: if type(metadata) is dict:
for i in metadata: for i in metadata:
try: try:
@ -100,6 +100,7 @@ def validate_metadata(metadata, block_data) -> bool:
try: try:
metadata['time'] metadata['time']
except KeyError: except KeyError:
logger.warn("Time header not set")
return False return False
nonce = bytesconverter.bytes_to_str(onionrcrypto.hashers.sha3_hash(block_data)) nonce = bytesconverter.bytes_to_str(onionrcrypto.hashers.sha3_hash(block_data))

View File

@ -114,8 +114,8 @@ var getStats = function(){
"token": webpass "token": webpass
}}) }})
.then((resp) => resp.text()) .then((resp) => resp.text())
.then(function(totalRec) { .then(function(resp) {
totalRec.innerText = totalRec totalRec.innerText = resp
}) })
fetch('/lastconnect', { fetch('/lastconnect', {
headers: { headers: {

View File

@ -27,7 +27,6 @@ class OnionrConfig(unittest.TestCase):
self.assertEqual(conf['general']['ephemeral_tunnels'], False) self.assertEqual(conf['general']['ephemeral_tunnels'], False)
self.assertEqual(conf['general']['hide_created_blocks'], True) self.assertEqual(conf['general']['hide_created_blocks'], True)
self.assertEqual(conf['general']['insert_deniable_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_block_pow'], 5)
self.assertEqual(conf['general']['minimum_send_pow'], 5) self.assertEqual(conf['general']['minimum_send_pow'], 5)
self.assertEqual(conf['general']['public_key'], '') self.assertEqual(conf['general']['public_key'], '')