mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
parent
9a0cf63769
commit
0180abc179
1 changed files with 6 additions and 0 deletions
|
@ -40,6 +40,10 @@ def serialize_header(res):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def deserialize_header(s, height):
|
def deserialize_header(s, height):
|
||||||
|
if not s:
|
||||||
|
raise Exception('Invalid header: {}'.format(s))
|
||||||
|
if len(s) != 80:
|
||||||
|
raise Exception('Invalid header length: {}'.format(len(s)))
|
||||||
hex_to_int = lambda s: int('0x' + bh2u(s[::-1]), 16)
|
hex_to_int = lambda s: int('0x' + bh2u(s[::-1]), 16)
|
||||||
h = {}
|
h = {}
|
||||||
h['version'] = hex_to_int(s[0:4])
|
h['version'] = hex_to_int(s[0:4])
|
||||||
|
@ -255,6 +259,8 @@ class Blockchain(util.PrintError):
|
||||||
with open(name, 'rb') as f:
|
with open(name, 'rb') as f:
|
||||||
f.seek(delta * 80)
|
f.seek(delta * 80)
|
||||||
h = f.read(80)
|
h = f.read(80)
|
||||||
|
if len(h) < 80:
|
||||||
|
raise Exception('Expected to read a full header. This was only {} bytes'.format(len(h)))
|
||||||
elif not os.path.exists(util.get_headers_dir(self.config)):
|
elif not os.path.exists(util.get_headers_dir(self.config)):
|
||||||
raise Exception('Electrum datadir does not exist. Was it deleted while running?')
|
raise Exception('Electrum datadir does not exist. Was it deleted while running?')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue