Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor apply_successful_verification: dead code #2219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions electroncash/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,11 @@ def on_block_headers(self, interface, request, response):
self.connection_down(interface.server, blacklist=True)
return

if not self.apply_successful_verification(interface, request_params[2], result['root']):
is_valid_checkpoint = self.verify_checkpoint(interface,
request_params[2], result['root'])
if not is_valid_checkpoint:
return

# We connect this verification chunk into the longest chain.
target_blockchain = self.blockchains[0]
else:
Expand Down Expand Up @@ -1627,16 +1630,17 @@ def request_initial_proof_and_headers(self, interface):
interface.set_mode(Interface.MODE_DEFAULT)
self._process_latest_tip(interface)

def apply_successful_verification(self, interface, checkpoint_height, checkpoint_root):
def verify_checkpoint(self, interface, checkpoint_height, checkpoint_root,
is_checkpoint_generation_enabled=False)-> bool:
known_roots = [ v['root'] for v in self.checkpoint_servers_verified.values() if v['root'] is not None ]
if len(known_roots) > 0 and checkpoint_root != known_roots[0]:
interface.print_error("server sent inconsistent root '{}'".format(checkpoint_root))
self.connection_down(interface.server)
return False

self.checkpoint_servers_verified[interface.server]['root'] = checkpoint_root

# rt12 --- checkpoint generation currently disabled.
if False:
if is_checkpoint_generation_enabled:
interface.print_error("received verification {}".format(self.verifications_required))
self.verifications_required -= 1
if self.verifications_required > 0:
Expand All @@ -1653,8 +1657,7 @@ def apply_successful_verification(self, interface, checkpoint_height, checkpoint
self.init_headers_file()
self.verified_checkpoint = True

# rt12 --- checkpoint generation currently disabled.
if False:
if is_checkpoint_generation_enabled:
with self.interface_lock:
interfaces = list(self.interfaces.values())
for interface_entry in interfaces:
Expand Down