work on new block system
parent
2703731053
commit
ee04c6d2bf
|
@ -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 = ""
|
||||||
|
|
|
@ -96,8 +96,10 @@ 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()
|
filelocation = 'data/blocks/%s.dat' % self.getHash().decode()
|
||||||
|
except AttributeError:
|
||||||
|
filelocation = 'data/blocks/%s.dat' % self.getHash()
|
||||||
|
|
||||||
with open(filelocation, 'rb') as f:
|
with open(filelocation, 'rb') as f:
|
||||||
blockdata = f.read().decode('utf-8')
|
blockdata = f.read().decode('utf-8')
|
||||||
|
|
Loading…
Reference in New Issue