forked from penumbra-zone/penumbra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get height from grpc metadata for relevant ibc queries
- Loading branch information
Showing
5 changed files
with
143 additions
and
6 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use anyhow::anyhow; | ||
use ibc_proto::ibc::core::client::v1::Height; | ||
|
||
pub(crate) fn height_from_str(value: &str) -> anyhow::Result<Height> { | ||
let split: Vec<&str> = value.split('-').collect(); | ||
|
||
if split.len() != 2 { | ||
return Err(anyhow!("invalid height string")); | ||
} | ||
|
||
let revision_number = split[0] | ||
.parse::<u64>() | ||
.map_err(|e| anyhow!("failed to parse revision number"))?; | ||
|
||
let revision_height = split[1] | ||
.parse::<u64>() | ||
.map_err(|e| anyhow!("failed to parse revision height"))?; | ||
|
||
if revision_number == 0 && revision_height == 0 { | ||
return Err(anyhow!("height is zero")); | ||
} | ||
|
||
Ok(Height { | ||
revision_number, | ||
revision_height, | ||
}) | ||
} |