do not save expired blocks
parent
7b635c4fc9
commit
26f25f8fe4
|
@ -147,7 +147,8 @@ HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
|
||||||
torVersion = subprocess.Popen([self.torBinary, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
torVersion = subprocess.Popen([self.torBinary, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
for line in iter(torVersion.stdout.readline, b''):
|
for line in iter(torVersion.stdout.readline, b''):
|
||||||
if 'Tor 0.2.' in line.decode():
|
if 'Tor 0.2.' in line.decode():
|
||||||
logger.warn("Running 0.2.x Tor series, no support for v3 onion peers")
|
logger.error('Tor 0.3+ required')
|
||||||
|
sys.exit(1)
|
||||||
break
|
break
|
||||||
torVersion.kill()
|
torVersion.kill()
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,29 @@ class Onionr:
|
||||||
logger.error('Tor is not installed')
|
logger.error('Tor is not installed')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# If data folder does not exist
|
||||||
|
if not data_exists:
|
||||||
|
if not os.path.exists(self.dataDir + 'blocks/'):
|
||||||
|
os.mkdir(self.dataDir + 'blocks/')
|
||||||
|
|
||||||
|
# Copy default plugins into plugins folder
|
||||||
|
if not os.path.exists(plugins.get_plugins_folder()):
|
||||||
|
if os.path.exists('static-data/default-plugins/'):
|
||||||
|
names = [f for f in os.listdir("static-data/default-plugins/")]
|
||||||
|
shutil.copytree('static-data/default-plugins/', plugins.get_plugins_folder())
|
||||||
|
|
||||||
|
# Enable plugins
|
||||||
|
for name in names:
|
||||||
|
if not name in plugins.get_enabled_plugins():
|
||||||
|
plugins.enable(name, self)
|
||||||
|
|
||||||
|
for name in plugins.get_enabled_plugins():
|
||||||
|
if not os.path.exists(plugins.get_plugin_data_folder(name)):
|
||||||
|
try:
|
||||||
|
os.mkdir(plugins.get_plugin_data_folder(name))
|
||||||
|
except:
|
||||||
|
plugins.disable(name, onionr = self, stop_event = False)
|
||||||
|
|
||||||
self.communicatorInst = None
|
self.communicatorInst = None
|
||||||
self.onionrCore = core.Core()
|
self.onionrCore = core.Core()
|
||||||
self.onionrCore.onionrInst = self
|
self.onionrCore.onionrInst = self
|
||||||
|
@ -90,29 +113,6 @@ class Onionr:
|
||||||
|
|
||||||
self.debug = False # Whole application debugging
|
self.debug = False # Whole application debugging
|
||||||
|
|
||||||
# If data folder does not exist
|
|
||||||
if not data_exists:
|
|
||||||
if not os.path.exists(self.dataDir + 'blocks/'):
|
|
||||||
os.mkdir(self.dataDir + 'blocks/')
|
|
||||||
|
|
||||||
# Copy default plugins into plugins folder
|
|
||||||
if not os.path.exists(plugins.get_plugins_folder()):
|
|
||||||
if os.path.exists('static-data/default-plugins/'):
|
|
||||||
names = [f for f in os.listdir("static-data/default-plugins/") if not os.path.isfile(f)]
|
|
||||||
shutil.copytree('static-data/default-plugins/', plugins.get_plugins_folder())
|
|
||||||
|
|
||||||
# Enable plugins
|
|
||||||
for name in names:
|
|
||||||
if not name in plugins.get_enabled_plugins():
|
|
||||||
plugins.enable(name, self)
|
|
||||||
|
|
||||||
for name in plugins.get_enabled_plugins():
|
|
||||||
if not os.path.exists(plugins.get_plugin_data_folder(name)):
|
|
||||||
try:
|
|
||||||
os.mkdir(plugins.get_plugin_data_folder(name))
|
|
||||||
except:
|
|
||||||
plugins.disable(name, onionr = self, stop_event = False)
|
|
||||||
|
|
||||||
# Get configuration
|
# Get configuration
|
||||||
if type(config.get('client.webpassword')) is type(None):
|
if type(config.get('client.webpassword')) is type(None):
|
||||||
config.set('client.webpassword', base64.b16encode(os.urandom(32)).decode('utf-8'), savefile=True)
|
config.set('client.webpassword', base64.b16encode(os.urandom(32)).decode('utf-8'), savefile=True)
|
||||||
|
|
|
@ -278,6 +278,7 @@ class OnionrUtils:
|
||||||
break
|
break
|
||||||
if (self.getEpoch() - metadata[i]) > maxAge:
|
if (self.getEpoch() - metadata[i]) > maxAge:
|
||||||
logger.warn('Block is outdated: %s' % (metadata[i],))
|
logger.warn('Block is outdated: %s' % (metadata[i],))
|
||||||
|
break
|
||||||
elif i == 'expire':
|
elif i == 'expire':
|
||||||
try:
|
try:
|
||||||
assert int(metadata[i]) > self.getEpoch()
|
assert int(metadata[i]) > self.getEpoch()
|
||||||
|
|
Loading…
Reference in New Issue