Skip to content

Commit

Permalink
Merge pull request #4223 from anoma/tomas/next-epoch-followup
Browse files Browse the repository at this point in the history
client/rpc: small improvements
  • Loading branch information
mergify[bot] authored Jan 9, 2025
2 parents 92367b0 + e67f96d commit 9527ea9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/apps_lib/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use namada_sdk::rpc::{
self, enriched_bonds_and_unbonds, format_denominated_amount, query_epoch,
TxResponse,
};
use namada_sdk::state::LastBlock;
use namada_sdk::storage::BlockResults;
use namada_sdk::tendermint_rpc::endpoint::status;
use namada_sdk::time::DateTimeUtc;
Expand Down Expand Up @@ -90,7 +91,7 @@ pub async fn query_and_print_masp_epoch(context: &impl Namada) -> MaspEpoch {
/// begin.
pub async fn query_and_print_next_epoch_info(context: &impl Namada) {
println!();
let current_time = query_block(context).await.unwrap();
query_block(context).await.unwrap();

let current_epoch = query_epoch(context.client()).await.unwrap();
let (this_epoch_first_height, epoch_duration) =
Expand All @@ -105,6 +106,8 @@ pub async fn query_and_print_next_epoch_info(context: &impl Namada) {
let first_block_time = this_epoch_first_height_header.time;
let next_epoch_time = first_block_time + epoch_duration.min_duration;

#[allow(clippy::disallowed_methods)]
let current_time = DateTimeUtc::now();
let seconds_left = next_epoch_time.time_diff(current_time).0;
let time_remaining_str = convert_to_hours(seconds_left);

Expand Down Expand Up @@ -166,7 +169,7 @@ pub async fn query_and_print_status(
}

/// Query the last committed block
pub async fn query_block(context: &impl Namada) -> Option<DateTimeUtc> {
pub async fn query_block(context: &impl Namada) -> Option<LastBlock> {
let block = namada_sdk::rpc::query_block(context.client())
.await
.unwrap();
Expand All @@ -178,7 +181,7 @@ pub async fn query_block(context: &impl Namada) -> Option<DateTimeUtc> {
block.height,
block.time
);
Some(block.time)
Some(block)
}
None => {
display_line!(context.io(), "No block has been committed yet.");
Expand Down

0 comments on commit 9527ea9

Please sign in to comment.