tMerge pull request #4411 from kyuupichan/get_chunk - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 0fb3d3c825b721f21206ed7ff94c1f0be1d2f27d DIR parent e0a6b082d2c608e644872632705338d073d382b2 HTML Author: ThomasV <thomasv@electrum.org> Date: Wed, 6 Jun 2018 09:13:06 +0200 Merge pull request #4411 from kyuupichan/get_chunk Stop using deprecated RPC blockchain.block.get_chunk Diffstat: M lib/network.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- DIR diff --git a/lib/network.py b/lib/network.py t@@ -561,8 +561,8 @@ class Network(util.DaemonThread): if error is None: self.relay_fee = int(result * COIN) if result is not None else None self.print_error("relayfee", self.relay_fee) - elif method == 'blockchain.block.get_chunk': - self.on_get_chunk(interface, response) + elif method == 'blockchain.block.headers': + self.on_block_headers(interface, response) elif method == 'blockchain.block.get_header': self.on_get_header(interface, response) t@@ -766,9 +766,11 @@ class Network(util.DaemonThread): return interface.print_error("requesting chunk %d" % index) self.requested_chunks.add(index) - self.queue_request('blockchain.block.get_chunk', [index], interface) + height = index * 2016 + self.queue_request('blockchain.block.headers', [height, 2016], + interface) - def on_get_chunk(self, interface, response): + def on_block_headers(self, interface, response): '''Handle receiving a chunk of block headers''' error = response.get('error') result = response.get('result') t@@ -777,15 +779,17 @@ class Network(util.DaemonThread): if result is None or params is None or error is not None: interface.print_error(error or 'bad response') return - index = params[0] # Ignore unsolicited chunks - if index not in self.requested_chunks: + height = params[0] + index = height // 2016 + if index * 2016 != height or index not in self.requested_chunks: interface.print_error("received chunk %d (unsolicited)" % index) return else: interface.print_error("received chunk %d" % index) self.requested_chunks.remove(index) - connect = blockchain.connect_chunk(index, result) + hexdata = result['hex'] + connect = blockchain.connect_chunk(index, hexdata) if not connect: self.connection_down(interface.server) return