-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blockchain: Optimize old block ver upgrade checks.
Currently the code that rejects old block versions once the majority of the network has upgraded is performed using a loop that iterates backwards from latest enforced block version while checking for a majority upgrade at each version. This is inefficient for blocks early in the chain since it means multiple versions need to be checked when it isn't really necessary. This optimizes the relevant code by taking into account that the relevant enforcement semantics reduce to the following: - Block versions greater than or equal to the latest enforced block version can never be rejected for being old - Block versions must be rejected when the majority of the network has upgraded to ANY version greater than that version The following timing information obtained from profiling shows the overall reduction achieved with the optimized code for mainnet: existing: Total time to check old versions for 645603 headers: 10.61118s optimized: Total time to check old versions for 645603 headers: 3.52555s
- Loading branch information
Showing
1 changed file
with
49 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters