keep connection open with a manually selected server, even if they fail passing the checkpoint
This commit is contained in:
parent
23e51e7c9e
commit
31fc9b78af
|
@ -693,6 +693,7 @@ class Network(util.DaemonThread):
|
||||||
def new_interface(self, server, socket):
|
def new_interface(self, server, socket):
|
||||||
self.add_recent_server(server)
|
self.add_recent_server(server)
|
||||||
self.interfaces[server] = interface = Interface(server, socket)
|
self.interfaces[server] = interface = Interface(server, socket)
|
||||||
|
interface.failed_checkpoint = False
|
||||||
self.queue_request('blockchain.block.get_header', [self.blockchain.checkpoint_height], interface)
|
self.queue_request('blockchain.block.get_header', [self.blockchain.checkpoint_height], interface)
|
||||||
self.queue_request('blockchain.headers.subscribe', [], interface)
|
self.queue_request('blockchain.headers.subscribe', [], interface)
|
||||||
if server == self.default_server:
|
if server == self.default_server:
|
||||||
|
@ -764,6 +765,7 @@ class Network(util.DaemonThread):
|
||||||
self.notify('updated')
|
self.notify('updated')
|
||||||
else:
|
else:
|
||||||
self.request_chunk(interface, data, idx)
|
self.request_chunk(interface, data, idx)
|
||||||
|
self.notify('updated')
|
||||||
|
|
||||||
def request_header(self, interface, data, height):
|
def request_header(self, interface, data, height):
|
||||||
interface.print_error("requesting header %d" % height)
|
interface.print_error("requesting header %d" % height)
|
||||||
|
@ -777,8 +779,11 @@ class Network(util.DaemonThread):
|
||||||
'''Handle receiving a single block header'''
|
'''Handle receiving a single block header'''
|
||||||
# close connection if header does not pass checkpoint
|
# close connection if header does not pass checkpoint
|
||||||
if not self.blockchain.pass_checkpoint(response['result']):
|
if not self.blockchain.pass_checkpoint(response['result']):
|
||||||
interface.print_error("header did not pass checkpoint, dismissing interface", interface.host)
|
if interface == self.interface and not auto_connect:
|
||||||
self.connection_down(interface.server)
|
interface.failed_checkpoint = True
|
||||||
|
else:
|
||||||
|
interface.print_error("header did not pass checkpoint, dismissing interface")
|
||||||
|
self.connection_down(interface.server)
|
||||||
return
|
return
|
||||||
if self.blockchain.downloading_headers:
|
if self.blockchain.downloading_headers:
|
||||||
return
|
return
|
||||||
|
@ -787,6 +792,9 @@ class Network(util.DaemonThread):
|
||||||
req_height = data.get('header_height', -1)
|
req_height = data.get('header_height', -1)
|
||||||
# Ignore unsolicited headers
|
# Ignore unsolicited headers
|
||||||
if req_if == interface and req_height == response['params'][0]:
|
if req_if == interface and req_height == response['params'][0]:
|
||||||
|
if interface.failed_checkpoint:
|
||||||
|
self.bc_requests.popleft()
|
||||||
|
return
|
||||||
next_height = self.blockchain.connect_header(data['chain'], response['result'])
|
next_height = self.blockchain.connect_header(data['chain'], response['result'])
|
||||||
# If not finished, get the next header
|
# If not finished, get the next header
|
||||||
if next_height in [True, False]:
|
if next_height in [True, False]:
|
||||||
|
|
Loading…
Reference in New Issue