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

get height from grpc metadata for relevant ibc queries #3

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

noot
Copy link
Owner

@noot noot commented Sep 11, 2024

Describe your changes

Issue ticket number and link

Checklist before requesting a review

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    REPLACE THIS TEXT WITH RATIONALE (CAN BE BRIEF)

Comment on lines +39 to +57
let Some(height_val) = request.metadata().get("height") else {
return Err(tonic::Status::aborted("missing height"));
};

let height_str: &str = height_val
.to_str()
.map_err(|e| tonic::Status::aborted(format!("invalid height: {e}")))?;

let snapshot = if height_str == "0" {
self.storage.latest_snapshot()
} else {
let height = height_from_str(height_str)
.map_err(|e| tonic::Status::aborted(format!("couldn't get snapshot: {e}")))?;

self.storage
.snapshot(height.revision_height as u64)
.ok_or(tonic::Status::aborted(format!("invalid height")))?
};

Choose a reason for hiding this comment

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

I think this code is duplicated 6 times overall? In the new utils module, this could be shortened with a fn snapshot_from_metadata or something like that?

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