Skip to content

Commit

Permalink
relayer: Removed uses of chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabaluev committed Dec 13, 2021
1 parent d101aaf commit 672d206
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ibc = { version = "0.9.0", path = "../modules" }
ibc-proto = { version = "0.13.0", path = "../proto" }
ibc-telemetry = { version = "0.9.0", path = "../telemetry", optional = true }

chrono = { version = "0.4.19", default-features = false, features = ["clock"] }
subtle-encoding = "0.5"
async-trait = "0.1.50"
humantime-serde = "1.0.0"
Expand Down
6 changes: 2 additions & 4 deletions relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::{fmt, thread, time::Instant};

use bech32::{ToBase32, Variant};
use bitcoin::hashes::hex::ToHex;
use chrono::DateTime;
use itertools::Itertools;
use prost::Message;
use prost_types::Any;
Expand Down Expand Up @@ -56,7 +55,6 @@ use ibc::core::ics24_host::{ClientUpgradePath, Path, IBC_QUERY_PATH, SDK_UPGRADE
use ibc::events::{from_tx_response_event, IbcEvent};
use ibc::query::{QueryTxHash, QueryTxRequest};
use ibc::signer::Signer;
use ibc::timestamp::Timestamp;
use ibc::Height as ICSHeight;
use ibc::{downcast, query::QueryBlockRequest};
use ibc_proto::cosmos::auth::v1beta1::{BaseAccount, EthAccount, QueryAccountRequest};
Expand Down Expand Up @@ -1098,15 +1096,15 @@ impl ChainEndpoint for CosmosSdkChain {
crate::time!("query_status");
let status = self.status()?;

let time = DateTime::from(status.sync_info.latest_block_time);
let time = status.sync_info.latest_block_time;
let height = ICSHeight {
revision_number: ChainId::chain_version(status.node_info.network.as_str()),
revision_height: u64::from(status.sync_info.latest_block_height),
};

Ok(StatusResponse {
height,
timestamp: Timestamp::from_datetime(time),
timestamp: time.into(),
})
}

Expand Down
3 changes: 1 addition & 2 deletions relayer/src/foreign_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::{fmt, time::Duration};
use std::thread;
use std::time::Instant;

use chrono::Utc;
use itertools::Itertools;
use prost_types::Any;
use tracing::{debug, error, info, trace, warn};
Expand Down Expand Up @@ -569,7 +568,7 @@ impl<DstChain: ChainHandle, SrcChain: ChainHandle> ForeignClient<DstChain, SrcCh
// we can backoff between subsequent client updates.
let refresh_window = client_state.refresh_period();
// Compute the duration since the last update of this client
let elapsed = Timestamp::from_datetime(Utc::now()).duration_since(&last_update_time);
let elapsed = Timestamp::now().duration_since(&last_update_time);

if client_state.is_frozen() || client_state.expired(elapsed.unwrap_or_default()) {
return Err(ForeignClientError::expired_or_frozen(
Expand Down
4 changes: 1 addition & 3 deletions relayer/src/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::fmt::{Display, Formatter};
use core::str::FromStr;
use core::time::Duration;

use chrono::Utc;
use flex_error::{define_error, DetailOnly};
use ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer;
use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId};
Expand Down Expand Up @@ -98,8 +97,7 @@ pub fn build_and_send_transfer_messages<SrcChain: ChainHandle, DstChain: ChainHa
let timeout_timestamp = if opts.timeout_seconds == Duration::from_secs(0) {
Timestamp::none()
} else {
(Timestamp::from_datetime(Utc::now()) + opts.timeout_seconds)
.map_err(PacketError::timestamp_overflow)?
(Timestamp::now() + opts.timeout_seconds).map_err(PacketError::timestamp_overflow)?
};

let timeout_height = if opts.timeout_height_offset == 0 {
Expand Down

0 comments on commit 672d206

Please sign in to comment.