Browse Source

fix request_chunk

3.3.3.1
SomberNight 6 years ago
parent
commit
2157eae499
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/network.py

8
electrum/network.py

@ -730,15 +730,13 @@ class Network(PrintError):
if session is None: session = self.interface.session if session is None: session = self.interface.session
index = height // 2016 index = height // 2016
size = 2016 size = 2016
if tip is not None and height + 2016 >= tip: if tip is not None:
size = tip - height size = min(size, tip - index * 2016)
#if index * 2016 < height: size = max(size, 0)
# size = height - index * 2016
res = await session.send_request('blockchain.block.headers', [index * 2016, size]) res = await session.send_request('blockchain.block.headers', [index * 2016, size])
conn = self.blockchain().connect_chunk(index, res['hex']) conn = self.blockchain().connect_chunk(index, res['hex'])
if not conn: if not conn:
return conn, 0 return conn, 0
self.blockchain().save_chunk(index, bfh(res['hex']))
return conn, res['count'] return conn, res['count']
@with_interface_lock @with_interface_lock

Loading…
Cancel
Save