From 1c23f6e0bbc07c947c0c6b3e40d1b89be066cfd2 Mon Sep 17 00:00:00 2001 From: deniallugo Date: Tue, 16 Aug 2022 14:06:34 +0200 Subject: [PATCH] Fix default timestamp Signed-off-by: deniallugo --- core/lib/types/src/tx/change_pubkey.rs | 5 ++--- core/lib/types/src/tx/primitives/time_range.rs | 2 +- core/lib/types/src/tx/transfer.rs | 5 ++--- core/lib/types/src/tx/withdraw.rs | 5 ++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/lib/types/src/tx/change_pubkey.rs b/core/lib/types/src/tx/change_pubkey.rs index da41a4f3eb..bd657ef82d 100644 --- a/core/lib/types/src/tx/change_pubkey.rs +++ b/core/lib/types/src/tx/change_pubkey.rs @@ -289,9 +289,8 @@ impl ChangePubKey { out.extend_from_slice(&self.fee_token.to_be_bytes()); out.extend_from_slice(&pack_fee_amount(&self.fee)); out.extend_from_slice(&self.nonce.to_be_bytes()); - if let Some(time_range) = &self.time_range { - out.extend_from_slice(&time_range.as_be_bytes()); - } + let time_range = self.time_range.unwrap_or_default(); + out.extend_from_slice(&time_range.as_be_bytes()); out } diff --git a/core/lib/types/src/tx/primitives/time_range.rs b/core/lib/types/src/tx/primitives/time_range.rs index d495ea64bc..d5e8f23f05 100644 --- a/core/lib/types/src/tx/primitives/time_range.rs +++ b/core/lib/types/src/tx/primitives/time_range.rs @@ -45,7 +45,7 @@ impl Default for TimeRange { fn default() -> Self { Self { valid_from: 0, - valid_until: u64::max_value(), + valid_until: u64::MAX, } } } diff --git a/core/lib/types/src/tx/transfer.rs b/core/lib/types/src/tx/transfer.rs index 17c6674f16..c1413ec551 100644 --- a/core/lib/types/src/tx/transfer.rs +++ b/core/lib/types/src/tx/transfer.rs @@ -137,9 +137,8 @@ impl Transfer { out.extend_from_slice(&pack_token_amount(&self.amount)); out.extend_from_slice(&pack_fee_amount(&self.fee)); out.extend_from_slice(&self.nonce.to_be_bytes()); - if let Some(time_range) = &self.time_range { - out.extend_from_slice(&time_range.as_be_bytes()); - } + let time_range = self.time_range.unwrap_or_default(); + out.extend_from_slice(&time_range.as_be_bytes()); out } diff --git a/core/lib/types/src/tx/withdraw.rs b/core/lib/types/src/tx/withdraw.rs index 005c7c9fce..919726b8b0 100644 --- a/core/lib/types/src/tx/withdraw.rs +++ b/core/lib/types/src/tx/withdraw.rs @@ -141,9 +141,8 @@ impl Withdraw { out.extend_from_slice(&self.amount.to_u128().unwrap().to_be_bytes()); out.extend_from_slice(&pack_fee_amount(&self.fee)); out.extend_from_slice(&self.nonce.to_be_bytes()); - if let Some(time_range) = &self.time_range { - out.extend_from_slice(&time_range.as_be_bytes()); - } + let time_range = self.time_range.unwrap_or_default(); + out.extend_from_slice(&time_range.as_be_bytes()); out }