Skip to content

Commit

Permalink
fix: revise NonZeros (#5278)
Browse files Browse the repository at this point in the history
Signed-off-by: Shunkichi Sato <[email protected]>
  • Loading branch information
s8sato authored Jan 20, 2025
1 parent 13d953d commit d96f6f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crates/iroha_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ mod multisig {
proposal_status.instructions = proposal_value.instructions;
proposal_status.proposed_at = {
let proposed_at = Duration::from_secs(
Duration::from_millis(proposal_value.proposed_at_ms.into()).as_secs(),
Duration::from_millis(proposal_value.proposed_at_ms).as_secs(),
);
SystemTime::UNIX_EPOCH
.checked_add(proposed_at)
Expand All @@ -1592,7 +1592,7 @@ mod multisig {
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap();
let expires_at = Duration::from_millis(proposal_value.expires_at_ms.into());
let expires_at = Duration::from_millis(proposal_value.expires_at_ms);
Duration::from_secs(expires_at.saturating_sub(now).as_secs()).into()
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Validation and execution logic of instructions for multisig transactions
use alloc::{collections::btree_set::BTreeSet, vec};
use core::num::NonZeroU64;

use iroha_smart_contract::data_model::query::error::QueryExecutionFail;

Expand Down Expand Up @@ -189,15 +188,13 @@ fn proposal_value<V: Execute + Visit + ?Sized>(
.map_err(metadata_conversion_error)
}

fn now_ms<V: Execute + Visit + ?Sized>(executor: &V) -> NonZeroU64 {
fn now_ms<V: Execute + Visit + ?Sized>(executor: &V) -> u64 {
executor
.context()
.curr_block
.creation_time()
.as_millis()
.try_into()
.ok()
.and_then(NonZeroU64::new)
.dbg_expect("shouldn't overflow within 584942417 years")
}

Expand Down
4 changes: 2 additions & 2 deletions crates/iroha_executor_data_model/src/isi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ pub mod multisig {
/// Proposal contents
pub instructions: Vec<InstructionBox>,
/// Time in milliseconds at which the proposal was made
pub proposed_at_ms: NonZeroU64,
pub proposed_at_ms: u64,
/// Time in milliseconds at which the proposal will expire
pub expires_at_ms: NonZeroU64,
pub expires_at_ms: u64,
/// List of approvers of the proposal so far
pub approvals: BTreeSet<AccountId>,
/// In case this proposal is some relaying approval, indicates if it has executed or not
Expand Down
4 changes: 2 additions & 2 deletions docs/source/references/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3041,11 +3041,11 @@
},
{
"name": "proposed_at_ms",
"type": "NonZero<u64>"
"type": "u64"
},
{
"name": "expires_at_ms",
"type": "NonZero<u64>"
"type": "u64"
},
{
"name": "approvals",
Expand Down

0 comments on commit d96f6f7

Please sign in to comment.