Skip to content

Commit

Permalink
Creation slot from seconds instead of nanoseconds (#1729)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Dec 1, 2023
1 parent c9b30af commit 59cfa35
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl TransactionBuilder {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_nanos() as u64,
.as_secs(),
)
});
#[cfg(not(feature = "std"))]
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl ProtocolParameters {
2_u32.pow(self.slots_per_epoch_exponent() as u32)
}

/// Gets a [`SlotIndex`] from a unix timestamp.
/// Gets a [`SlotIndex`] from a unix timestamp in seconds.
pub fn slot_index(&self, timestamp: u64) -> SlotIndex {
SlotIndex::from_timestamp(
timestamp,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/slot/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl SlotIndex {
Self(*epoch_index << slots_per_epoch_exponent)
}

/// Gets the slot index of a unix timestamp.
/// Gets the slot index of a unix timestamp in seconds.
/// Slots are counted starting from `1` with `0` being reserved for times before the genesis.
pub fn from_timestamp(timestamp: u64, genesis_unix_timestamp: u64, slot_duration_in_seconds: u8) -> Self {
timestamp
Expand Down

0 comments on commit 59cfa35

Please sign in to comment.