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

finalized_block_height getter for FinalityView #52

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

mzabaluev
Copy link
Collaborator

Add finalized_block_height method for FinalityView, retrieving a previously set block height.

Add finalized_block_height method for FinalityView,
retrieving a previously set block height.
This is needed for sanity checks.
/// If [`set_finalized_block_height`] has never been called on this
/// instance, `None` is returned.
pub fn finalized_block_height(&self) -> Option<u64> {
let fin_ledger_info = self.finalized_ledger_info.read().unwrap();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure we want to unwrap ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lock acquisition. If it returns an error, the lock is poisoned, meaning some other thread has crashed while holding the lock. So it's a condition fatal enough to crash in turn.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, it's an invariant violation for us not to do this. But, I think maybe we should log and then panic to be a little less opaque.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the poisoned lock panic is informative enough. The only "integration" issue is that it is printed on stderr, but perhaps our infrastructure should capture process output for unexpected things like this.

@mzabaluev mzabaluev merged commit 1c63a73 into movement Aug 6, 2024
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.

4 participants