work on new block system

master
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':
resp = ''
if self._utils.validateHash(data):
if os.path.exists('data/blocks/' + data + '.db'):
try:
block = Block(data, core=self._core)()
resp = base64.b64encode(block.getRaw())
except TypeError:
resp = ""
if not os.path.exists('data/blocks/' + data + '.db'):
block = Block(data.encode(), core=self._core)
resp = base64.b64encode(block.getRaw()).decode()
if len(resp) == 0:
abort(404)
resp = ""

View File

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