diff --git a/onionr/onionr.py b/onionr/onionr.py index 9e90ebc3..3e386555 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -475,7 +475,7 @@ class Onionr: with open(plugins.get_plugins_folder(plugin_name) + '/main.py', 'a') as main: contents = '' with open('static-data/default_plugin.py', 'rb') as file: - contents = file.read() + contents = file.read().decode() # TODO: Fix $user. os.getlogin() is B U G G Y main.write(contents.replace('$user', 'some random developer').replace('$date', datetime.datetime.now().strftime('%Y-%m-%d')).replace('$name', plugin_name)) diff --git a/onionr/onionrblockapi.py b/onionr/onionrblockapi.py index 23609072..6dc9029a 100644 --- a/onionr/onionrblockapi.py +++ b/onionr/onionrblockapi.py @@ -111,7 +111,7 @@ class Block: self.bheader = json.loads(self.getRaw()[:self.getRaw().index('\n')]) self.bcontent = self.getRaw()[self.getRaw().index('\n') + 1:] self.bmetadata = json.loads(self.getHeader('meta')) - self.parent = (None if not 'parent' in self.getMetadata() else Block(self.getMetadata('parent'))) + self.parent = (None if not 'parent' in self.getMetadata() else self.getMetadata('parent')) self.btype = self.getMetadata('type') self.powHash = self.getMetadata('powHash') self.powToken = self.getMetadata('powToken') @@ -263,6 +263,14 @@ class Block: - (Block): the Block's parent ''' + if type(self.parent) == str: + if self.parent == self.getHash(): + self.parent = self + elif Block.exists(self.parent): + self.parent = Block(self.getMetadata('parent')) + else: + self.parent = None + return self.parent def getDate(self): @@ -459,7 +467,6 @@ class Block: if relevant: relevant_blocks.append(block) - if bool(reverse): relevant_blocks.reverse()