network: call switch_lagging after catch up

This commit is contained in:
ThomasV 2017-07-19 18:32:48 +02:00
parent b243772d68
commit 1457a869d3
1 changed files with 4 additions and 3 deletions

View File

@ -487,6 +487,7 @@ class Network(util.DaemonThread):
self.switch_to_interface(server) self.switch_to_interface(server)
else: else:
self.switch_lagging_interface() self.switch_lagging_interface()
self.notify('updated')
def switch_to_random_interface(self): def switch_to_random_interface(self):
'''Switch to a random connected server other than the current one''' '''Switch to a random connected server other than the current one'''
@ -505,7 +506,6 @@ class Network(util.DaemonThread):
if filtered: if filtered:
choice = random.choice(filtered) choice = random.choice(filtered)
self.switch_to_interface(choice) self.switch_to_interface(choice)
self.notify('updated')
def switch_to_interface(self, server): def switch_to_interface(self, server):
'''Switch to server as our interface. If no connection exists nor '''Switch to server as our interface. If no connection exists nor
@ -879,6 +879,7 @@ class Network(util.DaemonThread):
# exit catch_up state # exit catch_up state
interface.print_error('catch up done', interface.blockchain.height()) interface.print_error('catch up done', interface.blockchain.height())
interface.blockchain.catch_up = None interface.blockchain.catch_up = None
self.switch_lagging_interface()
self.notify('updated') self.notify('updated')
elif interface.mode == 'default': elif interface.mode == 'default':
@ -979,16 +980,16 @@ class Network(util.DaemonThread):
b = blockchain.check_header(header) b = blockchain.check_header(header)
if b: if b:
interface.blockchain = b interface.blockchain = b
self.notify('interfaces')
self.switch_lagging_interface() self.switch_lagging_interface()
self.notify('interfaces')
return return
b = blockchain.can_connect(header) b = blockchain.can_connect(header)
if b: if b:
interface.blockchain = b interface.blockchain = b
b.save_header(header) b.save_header(header)
self.switch_lagging_interface()
self.notify('updated') self.notify('updated')
self.notify('interfaces') self.notify('interfaces')
self.switch_lagging_interface()
return return
tip = max([x.height() for x in self.blockchains.values()]) tip = max([x.height() for x in self.blockchains.values()])
if tip >=0: if tip >=0: