diff --git a/Cargo.lock b/Cargo.lock index 3f3fa3e6cd..d4633e3a42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] @@ -210,7 +210,7 @@ dependencies = [ "strum 0.16.0", "strum_macros 0.16.0", "thiserror", - "time", + "time 0.3.20", "tokio", "url", "uuid 0.8.2", @@ -249,7 +249,7 @@ dependencies = [ "serde", "serde_json", "thiserror", - "time", + "time 0.3.20", "tokio", "uuid 1.3.1", ] @@ -534,9 +534,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d1372b52fa64b8af7cf6e3848cfa2dadb81c21e810f144bdd9c26e21895235" +checksum = "24a6904aef64d73cf10ab17ebace7befb918b82164785cb89907993be7f83813" [[package]] name = "blake2" @@ -634,9 +634,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byte-tools" @@ -749,7 +749,7 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -774,9 +774,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "eef2b3ded6a26dfaec672a742c93c8cf6b689220324da509ec5caa20de55dc83" dependencies = [ "atty", "bitflags 1.3.2", @@ -791,9 +791,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.2.18" +version = "3.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "d756c5824fc5c0c1ee8e36000f576968dbcb2081def956c83fad6f40acd46f96" dependencies = [ "heck 0.4.1", "proc-macro-error", @@ -878,9 +878,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -2455,7 +2455,7 @@ dependencies = [ "serde_derive", "serde_json", "thiserror", - "time", + "time 0.3.20", "tokio", "uuid 0.7.4", ] @@ -2482,7 +2482,7 @@ dependencies = [ "serde_derive", "serde_json", "thiserror", - "time", + "time 0.3.20", "tokio", "url", "uuid 0.7.4", @@ -2518,7 +2518,7 @@ dependencies = [ "serde_json", "sha2 0.9.9", "sha3 0.9.1", - "time", + "time 0.3.20", "ursa", "uuid 0.8.2", "zeroize", @@ -2536,9 +2536,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f508063cc7bb32987c71511216bd5a32be15bccb6a80b52df8b9d7f01fc3aa2" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "lock_api" @@ -2688,11 +2688,11 @@ checksum = "4330eca86d39f2b52d0481aa1e90fe21bfa61f11b0bf9b48ab95595013cefe48" [[package]] name = "napi" -version = "2.12.5" +version = "2.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b29acdc6cc5c918c3eabd51d241b1c6dfa8914f3552fcfd76e1d7536934581" +checksum = "49ac8112fe5998579b22e29903c7b277fc7f91c7860c0236f35792caf8156e18" dependencies = [ - "bitflags 2.2.0", + "bitflags 2.2.1", "ctor 0.2.0", "napi-derive", "napi-sys", @@ -2708,10 +2708,11 @@ checksum = "882a73d9ef23e8dc2ebbffb6a6ae2ef467c0f18ac10711e4cc59c5485d41df0e" [[package]] name = "napi-derive" -version = "2.12.3" +version = "2.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2ac63101a19228b0881694cac07468d642fd10e4f943a9c9feebeebf1a4787" +checksum = "c47e0f395207c062e680a158f0624ec456c1dfb3c96a8cb888e0401506d50ae9" dependencies = [ + "cfg-if 1.0.0", "convert_case 0.6.0", "napi-derive-backend", "proc-macro2", @@ -2721,9 +2722,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.49" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e32b5bc4d803e40b783b0aa3fe488eac8711cfaa4c5c9915293dfd3d0b99925" +checksum = "0a83afae5b4ba6f98ed6e33a52da343fdeb66474f1162a38cde5a3d46eb054e7" dependencies = [ "convert_case 0.6.0", "once_cell", @@ -2892,9 +2893,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.50" +version = "0.10.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30d8bc91859781f0a943411186324d580f2bbeb71b452fe91ae344806af3f1" +checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" dependencies = [ "bitflags 1.3.2", "cfg-if 1.0.0", @@ -2924,9 +2925,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.85" +version = "0.9.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0" +checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ "cc", "libc", @@ -3071,9 +3072,9 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "polling" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be1c66a6add46bff50935c313dae30a5030cf8385c5206e8a95e9e9def974aa" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg 1.1.0", "bitflags 1.3.2", @@ -3399,9 +3400,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", @@ -3410,9 +3411,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "reqwest" @@ -4260,6 +4261,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +dependencies = [ + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + [[package]] name = "tinyvec" version = "1.6.0" @@ -4277,9 +4294,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" dependencies = [ "autocfg 1.1.0", "bytes", @@ -4289,14 +4306,14 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", @@ -4326,9 +4343,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite", @@ -4337,9 +4354,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -4372,11 +4389,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "cf9cf6a813d3f40c88b0b6b6f29a5c95c6cdbf97c1f9cc53fb820200f5ad814d" dependencies = [ - "cfg-if 1.0.0", "pin-project-lite", "tracing-core", ] @@ -4665,7 +4681,7 @@ dependencies = [ "sha2 0.9.9", "sha3 0.9.1", "subtle", - "time", + "time 0.1.45", "x25519-dalek", "zeroize", ] diff --git a/aries_vcx/Cargo.toml b/aries_vcx/Cargo.toml index f77de38d59..21fc777819 100644 --- a/aries_vcx/Cargo.toml +++ b/aries_vcx/Cargo.toml @@ -27,7 +27,7 @@ async-trait = "0.1.53" env_logger = "0.9.0" log = "0.4.16" chrono = "0.4.23" -time = "0.1.44" +time = "0.3.20" lazy_static = "1.3" rand = "0.7.3" serde = "1.0.97" diff --git a/aries_vcx/src/common/credentials/mod.rs b/aries_vcx/src/common/credentials/mod.rs index 5ba91ec559..6a922981bb 100644 --- a/aries_vcx/src/common/credentials/mod.rs +++ b/aries_vcx/src/common/credentials/mod.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, sync::Arc}; -use time::get_time; +use time::OffsetDateTime; use crate::core::profile::profile::Profile; use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult}; @@ -36,7 +36,7 @@ pub async fn get_cred_rev_id(profile: &Arc, cred_id: &str) -> VcxRe pub async fn is_cred_revoked(profile: &Arc, rev_reg_id: &str, rev_id: &str) -> VcxResult { let from = None; - let to = Some(get_time().sec as u64 + 100); + let to = Some(OffsetDateTime::now_utc().unix_timestamp() as u64 + 100); let rev_reg_delta = RevocationRegistryDelta::create_from_ledger(profile, rev_reg_id, from, to).await?; Ok(rev_reg_delta.revoked().iter().any(|s| s.to_string().eq(rev_id))) } diff --git a/aries_vcx/src/common/primitives/mod.rs b/aries_vcx/src/common/primitives/mod.rs index bcbc725543..74878fac6a 100644 --- a/aries_vcx/src/common/primitives/mod.rs +++ b/aries_vcx/src/common/primitives/mod.rs @@ -86,7 +86,7 @@ pub mod integration_tests { let ledger = Arc::clone(&setup.profile).inject_ledger(); let (id, _rev_reg, _timestamp) = ledger - .get_rev_reg(&rev_reg_id, time::get_time().sec as u64) + .get_rev_reg(&rev_reg_id, time::OffsetDateTime::now_utc().unix_timestamp() as u64) .await .unwrap(); diff --git a/aries_vcx/src/common/signing.rs b/aries_vcx/src/common/signing.rs index 2794feefee..01230ef705 100644 --- a/aries_vcx/src/common/signing.rs +++ b/aries_vcx/src/common/signing.rs @@ -10,7 +10,7 @@ use crate::errors::error::prelude::*; use crate::global::settings; async fn get_signature_data(wallet: &Arc, data: String, key: &str) -> VcxResult<(Vec, Vec)> { - let now: u64 = time::get_time().sec as u64; + let now: u64 = time::OffsetDateTime::now_utc().unix_timestamp() as u64; let mut sig_data = now.to_be_bytes().to_vec(); sig_data.extend(data.as_bytes()); diff --git a/aries_vcx/tests/test_creds_proofs.rs b/aries_vcx/tests/test_creds_proofs.rs index 041d1a49d6..bc61064a4a 100644 --- a/aries_vcx/tests/test_creds_proofs.rs +++ b/aries_vcx/tests/test_creds_proofs.rs @@ -253,7 +253,7 @@ mod integration_tests { DEFAULT_SCHEMA_ATTRS, ) .await; - let to = time::get_time().sec; + let to = time::OffsetDateTime::now_utc().unix_timestamp() as u64; let indy_proof_req = json!({ "nonce": "123432421212", "name": "proof_req_1", @@ -334,7 +334,7 @@ mod integration_tests { DEFAULT_SCHEMA_ATTRS, ) .await; - let to = time::get_time().sec; + let to = time::OffsetDateTime::now_utc().unix_timestamp() as u64; let indy_proof_req = json!({ "nonce": "123432421212", "name": "proof_req_1", diff --git a/aries_vcx/tests/test_creds_proofs_revocations.rs b/aries_vcx/tests/test_creds_proofs_revocations.rs index 2c5549eb3c..f1a18c3ef4 100644 --- a/aries_vcx/tests/test_creds_proofs_revocations.rs +++ b/aries_vcx/tests/test_creds_proofs_revocations.rs @@ -46,11 +46,12 @@ mod integration_tests { assert!(!issuer_credential.is_revoked(&institution.profile).await.unwrap()); - let time_before_revocation = time::get_time().sec as u64; + let time_before_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; info!("test_basic_revocation :: verifier :: Going to revoke credential"); revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg.rev_reg_id).await; + tokio::time::sleep(Duration::from_millis(1000)).await; - let time_after_revocation = time::get_time().sec as u64; + let time_after_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; assert!(issuer_credential.is_revoked(&institution.profile).await.unwrap()); @@ -468,7 +469,7 @@ mod integration_tests { assert!(!issuer_credential.is_revoked(&institution.profile).await.unwrap()); tokio::time::sleep(Duration::from_millis(1000)).await; - let time_before_revocation = time::get_time().sec as u64; + let time_before_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; tokio::time::sleep(Duration::from_millis(1000)).await; info!("test_revoked_credential_might_still_work :: verifier :: Going to revoke credential"); revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg.rev_reg_id).await; diff --git a/aries_vcx_core/Cargo.toml b/aries_vcx_core/Cargo.toml index f48c330ee6..a863e0b7a1 100644 --- a/aries_vcx_core/Cargo.toml +++ b/aries_vcx_core/Cargo.toml @@ -33,7 +33,7 @@ libvdrtools = { path = "../libvdrtools", optional = true } async-trait = "0.1.68" futures = { version = "0.3", default-features = false } serde_json = "1.0.95" -time = "0.1.44" +time = "0.3.20" serde = { version = "1.0.159", features = ["derive"] } rand = "0.7.3" log = "0.4.17" diff --git a/aries_vcx_core/src/indy/ledger/transactions.rs b/aries_vcx_core/src/indy/ledger/transactions.rs index c246da206e..49071db1a7 100644 --- a/aries_vcx_core/src/indy/ledger/transactions.rs +++ b/aries_vcx_core/src/indy/ledger/transactions.rs @@ -1,3 +1,4 @@ +use time::OffsetDateTime; use vdrtools::{DidValue, Locator}; use crate::common::ledger::transactions::{Request, Response}; @@ -597,7 +598,7 @@ pub async fn get_rev_reg_delta_json( let to = if let Some(_to) = to { _to as i64 } else { - time::get_time().sec + OffsetDateTime::now_utc().unix_timestamp() }; let req = libindy_build_get_revoc_reg_delta_request(&submitter_did, rev_reg_id, from, to).await?; diff --git a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs index c7a0eb5479..6a8b463a38 100644 --- a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs +++ b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs @@ -3,6 +3,7 @@ use std::collections::hash_map::RandomState; use std::collections::HashMap; use std::fmt::{Debug, Formatter}; use std::sync::Arc; +use time::OffsetDateTime; use vdr::ledger::requests::schema::{AttributeNames, Schema, SchemaV1}; use async_trait::async_trait; @@ -484,7 +485,7 @@ fn unimplemented_method_err(method_name: &str) -> AriesVcxCoreError { } fn current_epoch_time() -> i64 { - time::get_time().sec + OffsetDateTime::now_utc().unix_timestamp() as i64 } async fn _append_txn_author_agreement_to_request(request: PreparedRequest) -> VcxCoreResult { diff --git a/libvcx/Cargo.toml b/libvcx/Cargo.toml index c86003bb2d..d5b3c3f008 100644 --- a/libvcx/Cargo.toml +++ b/libvcx/Cargo.toml @@ -24,7 +24,7 @@ cfg-if = { version = "1.0" } env_logger = "0.9.0" log = "0.4.16" chrono = "0.4.23" -time = "0.1.44" +time = "0.3.20" lazy_static = "1.3" libc = "=0.2.139" rand = "0.7.3" diff --git a/libvcx_core/Cargo.toml b/libvcx_core/Cargo.toml index 9fa66c182a..8da81cf6d1 100644 --- a/libvcx_core/Cargo.toml +++ b/libvcx_core/Cargo.toml @@ -18,7 +18,7 @@ cfg-if = { version = "1.0" } env_logger = "0.9.0" log = "0.4.16" chrono = "0.4.23" -time = "0.1.44" +time = "0.3.20" lazy_static = "1.3" libc = "=0.2.139" rand = "0.7.3" diff --git a/libvdrtools/Cargo.toml b/libvdrtools/Cargo.toml index 7eaa66b92c..080c3052e9 100644 --- a/libvdrtools/Cargo.toml +++ b/libvdrtools/Cargo.toml @@ -42,7 +42,7 @@ serde_derive = "1.0.99" sha2 = "0.9" sha3 = "0.9" rmp-serde = "0.13.7" -time = "0.1.44" +time = "0.3.20" zmq = "0.9.2" lazy_static = "1.3" byteorder = "1.3.2" diff --git a/libvdrtools/src/domain/ledger/request.rs b/libvdrtools/src/domain/ledger/request.rs index bab4c10269..58b0c073c9 100644 --- a/libvdrtools/src/domain/ledger/request.rs +++ b/libvdrtools/src/domain/ledger/request.rs @@ -42,7 +42,8 @@ pub struct TxnAuthrAgrmtAcceptanceData { } fn get_req_id() -> u64 { - time::get_time().sec as u64 * (1e9 as u64) + time::get_time().nsec as u64 + time::OffsetDateTime::now_utc().unix_timestamp() as u64 * (1e9 as u64) + + time::OffsetDateTime::now_utc().unix_timestamp_nanos() as u64 } #[derive(Serialize, Deserialize, PartialEq, Debug)] diff --git a/libvdrtools/src/services/pool/networker.rs b/libvdrtools/src/services/pool/networker.rs index e58594ad5f..4cc76bff3c 100644 --- a/libvdrtools/src/services/pool/networker.rs +++ b/libvdrtools/src/services/pool/networker.rs @@ -4,7 +4,7 @@ use std::{ }; use rand::{prelude::SliceRandom, thread_rng}; -use time::Tm; +use time::OffsetDateTime; use crate::services::pool::{events::*, types::*}; use indy_api_types::errors::prelude::*; @@ -190,8 +190,8 @@ pub struct PoolConnection { ctx: zmq::Context, key_pair: zmq::CurveKeyPair, resend: Mutex>, - timeouts: Mutex>, - time_created: time::Tm, + timeouts: Mutex>, + time_created: time::OffsetDateTime, req_cnt: usize, active_timeout: i64, } @@ -223,7 +223,7 @@ impl PoolConnection { ctx: zmq::Context::new(), key_pair: zmq::CurveKeyPair::new().expect("FIXME"), resend: Mutex::new(HashMap::new()), - time_created: time::now(), + time_created: OffsetDateTime::now_utc(), timeouts: Mutex::new(HashMap::new()), req_cnt: 0, active_timeout, @@ -261,15 +261,21 @@ impl PoolConnection { .lock() .unwrap() .iter() - .map(|(key, value)| (key, (*value - time::now()).num_milliseconds())) + .map(|(key, value)| { + ( + key, + (*value - OffsetDateTime::now_utc()).whole_milliseconds(), + ) + }) .min_by(|&(_, ref val1), &(_, ref val2)| val1.cmp(&val2)) { - ((req_id.to_string(), node_alias.to_string()), timeout) + ((req_id.to_string(), node_alias.to_string()), timeout as i64) } else { - let time_from_start: Duration = time::now() - self.time_created; + let time_from_start = + (OffsetDateTime::now_utc() - self.time_created).whole_milliseconds() as i64; ( ("".to_string(), "".to_string()), - self.active_timeout * 1000 - time_from_start.num_milliseconds(), + self.active_timeout * 1000 - time_from_start, ) } } @@ -277,9 +283,10 @@ impl PoolConnection { fn is_active(&self) -> bool { trace!( "is_active >> time worked: {:?}", - time::now() - self.time_created + OffsetDateTime::now_utc() - self.time_created ); - let res = time::now() - self.time_created < Duration::seconds(self.active_timeout); + let res = + OffsetDateTime::now_utc() - self.time_created < Duration::seconds(self.active_timeout); trace!("is_active << {}", res); res } @@ -332,7 +339,7 @@ impl PoolConnection { .unwrap() .get_mut(&(req_id.to_string(), node_alias.to_string())) { - *timeout = time::now() + Duration::seconds(extended_timeout); + *timeout = OffsetDateTime::now_utc() + Duration::seconds(extended_timeout); } else { debug!("late REQACK for req_id {}, node {}", req_id, node_alias); } @@ -389,7 +396,7 @@ impl PoolConnection { } self.timeouts.lock().unwrap().insert( (req_id, self.nodes[idx].name.clone()), - time::now() + Duration::seconds(timeout), + OffsetDateTime::now_utc() + Duration::seconds(timeout), ); trace!("_send_msg_to_one_node <<"); Ok(()) @@ -495,8 +502,6 @@ pub mod networker_tests { #[cfg(test)] mod networker { - use std::ops::Sub; - use super::*; #[test] @@ -745,7 +750,7 @@ pub mod networker_tests { .cloned() .collect::>()[0]; let conn: &mut PoolConnection = networker.pool_connections.get_mut(&conn_id).unwrap(); - conn.time_created = time::now().sub(Duration::seconds(5)); + conn.time_created = OffsetDateTime::now_utc() - Duration::seconds(5); } #[test] @@ -894,8 +899,6 @@ pub mod networker_tests { #[cfg(test)] mod pool_connection { - use std::ops::Sub; - use super::*; #[test] @@ -971,7 +974,7 @@ pub mod networker_tests { assert!(conn.is_active()); - conn.time_created = time::now().sub(Duration::seconds(POOL_CON_ACTIVE_TO)); + conn.time_created = OffsetDateTime::now_utc() - Duration::seconds(POOL_CON_ACTIVE_TO); assert!(!conn.is_active()); } diff --git a/libvdrtools/src/services/pool/types.rs b/libvdrtools/src/services/pool/types.rs index 5a29eb36f5..a4b29cd4b2 100644 --- a/libvdrtools/src/services/pool/types.rs +++ b/libvdrtools/src/services/pool/types.rs @@ -555,7 +555,7 @@ pub struct ResendableRequest { pub request: String, pub start_node: usize, pub next_node: usize, - pub next_try_send_time: Option, + pub next_try_send_time: Option, } #[derive(Debug, PartialEq, Eq)] @@ -565,7 +565,7 @@ pub struct CommandProcess { pub accum_replies: Option, pub parent_cmd_ids: Vec, pub resendable_request: Option, - pub full_cmd_timeout: Option, + pub full_cmd_timeout: Option, } #[derive(Debug, PartialEq, Eq)]