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

chain: slight refactor in finality and ‘on chain’ check methods #7410

Merged
merged 3 commits into from
Sep 6, 2022

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Aug 13, 2022

Firstly, change is_on_current_chain method to return boolean status
rather than error if block is not on current chain. The method is
used in two places: in one it’s only used as a boolean predicate so
returned error is irrelevant; in the other one the caller performs
another check and duplicates code for creating the error. Changing
is_on_current_chain return bool simplifies both call sites.

Secondly, rewrite check_block_final_and_canonical to accept a list of
headers rather than operating on single block hash. (With that also
change ‘block’ in name into ‘blocks’). This has a few motivations:
i) it makes last final block header being fetched only once, ii) since
caller needs access to the block header this makes it so that header
is fetched only once and iii) moving fetching of the headers to the
caller will actually help slightly in upcoming efforts for cold
storage.

Firstly, change is_on_current_chain method to return boolean status
rather than error if block is not on current chain.  The method is
used in two places: in one it’s only used as a boolean predicate so
returned error is irrelevant; in the other one the caller performs
another check and duplicates code for creating the error.  Changing
is_on_current_chain return bool simplifies both call sites.

Secondly, rewrite check_block_final_and_canonical to accept a list of
headers rather than operating on single block hash.  (With that also
change ‘block’ in name into ‘blocks’).  This has a few motivations:
i) it makes last final block header being fetched only once, ii) since
caller needs access to the block header this makes it so that header
is fetched only once and iii) moving fetching of the headers to the
caller will actually help slightly in upcoming efforts for cold
storage.
@mina86 mina86 requested a review from a team as a code owner August 13, 2022 22:28
@mina86 mina86 requested review from mzhangmzz and removed request for mzhangmzz August 13, 2022 22:28
@mina86
Copy link
Contributor Author

mina86 commented Aug 22, 2022

@mzhangmzz, friendly ping.

@near-bulldozer near-bulldozer bot merged commit accc46c into near:master Sep 6, 2022
@mina86 mina86 deleted the f branch September 7, 2022 01:27
nikurt pushed a commit that referenced this pull request Sep 7, 2022
Firstly, change is_on_current_chain method to return boolean status
rather than error if block is not on current chain.  The method is
used in two places: in one it’s only used as a boolean predicate so
returned error is irrelevant; in the other one the caller performs
another check and duplicates code for creating the error.  Changing
is_on_current_chain return bool simplifies both call sites.

Secondly, rewrite check_block_final_and_canonical to accept a list of
headers rather than operating on single block hash.  (With that also
change ‘block’ in name into ‘blocks’).  This has a few motivations:
i) it makes last final block header being fetched only once, ii) since
caller needs access to the block header this makes it so that header
is fetched only once and iii) moving fetching of the headers to the
caller will actually help slightly in upcoming efforts for cold
storage.
nikurt pushed a commit that referenced this pull request Nov 9, 2022
Firstly, change is_on_current_chain method to return boolean status
rather than error if block is not on current chain.  The method is
used in two places: in one it’s only used as a boolean predicate so
returned error is irrelevant; in the other one the caller performs
another check and duplicates code for creating the error.  Changing
is_on_current_chain return bool simplifies both call sites.

Secondly, rewrite check_block_final_and_canonical to accept a list of
headers rather than operating on single block hash.  (With that also
change ‘block’ in name into ‘blocks’).  This has a few motivations:
i) it makes last final block header being fetched only once, ii) since
caller needs access to the block header this makes it so that header
is fetched only once and iii) moving fetching of the headers to the
caller will actually help slightly in upcoming efforts for cold
storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants