work on new block system

This commit is contained in:
Kevin Froman 2018-06-08 02:46:05 -05:00
parent 2703731053
commit ee04c6d2bf
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 8 additions and 8 deletions

View File

@ -211,12 +211,10 @@ class API:
elif action == 'getData': elif action == 'getData':
resp = '' resp = ''
if self._utils.validateHash(data): if self._utils.validateHash(data):
if os.path.exists('data/blocks/' + data + '.db'): if not os.path.exists('data/blocks/' + data + '.db'):
try: block = Block(data.encode(), core=self._core)
block = Block(data, core=self._core)() resp = base64.b64encode(block.getRaw()).decode()
resp = base64.b64encode(block.getRaw())
except TypeError:
resp = ""
if len(resp) == 0: if len(resp) == 0:
abort(404) abort(404)
resp = "" resp = ""

View File

@ -96,7 +96,9 @@ class Block:
if filelocation is None: if filelocation is None:
if self.getHash() is None: if self.getHash() is None:
return False return False
try:
filelocation = 'data/blocks/%s.dat' % self.getHash().decode()
except AttributeError:
filelocation = 'data/blocks/%s.dat' % self.getHash() filelocation = 'data/blocks/%s.dat' % self.getHash()
with open(filelocation, 'rb') as f: with open(filelocation, 'rb') as f: