Add an utility function to get the first timestamp of a slot#5316
Merged
bkchr merged 6 commits intoparitytech:masterfrom Aug 29, 2024
Merged
Add an utility function to get the first timestamp of a slot#5316bkchr merged 6 commits intoparitytech:masterfrom
bkchr merged 6 commits intoparitytech:masterfrom
Conversation
8633f8c to
441b6d3
Compare
davxy
reviewed
Aug 12, 2024
Comment on lines
+94
to
+95
| /// The first timestamp of the slot. Returns None if would overflow for given SlotDuration. | ||
| pub fn first_timestamp(&self, slot_duration: SlotDuration) -> Option<Timestamp> { |
Member
There was a problem hiding this comment.
Suggested change
| /// The first timestamp of the slot. Returns None if would overflow for given SlotDuration. | |
| pub fn first_timestamp(&self, slot_duration: SlotDuration) -> Option<Timestamp> { | |
| /// The timestamp of the slot given the duration. | |
| /// | |
| /// Returns `None` if would overflow for given `SlotDuration`. | |
| pub fn to_timestamp(self, slot_duration: SlotDuration) -> Option<Timestamp> { |
I'd rather change the api to this (Slot is Copy)
Member
There was a problem hiding this comment.
Or maybe just call it timestamp. Not really required to have any longer name.
Contributor
Author
There was a problem hiding this comment.
I've renamed to timestamp, but kept "first" in the documentation, because it returns the first timestamp of the slot
davxy
approved these changes
Aug 14, 2024
gilescope
reviewed
Aug 14, 2024
Co-authored-by: Squirrel <giles.cope@iohk.io>
Contributor
|
Review required! Latest push from author must always be reviewed |
davxy
reviewed
Aug 14, 2024
davxy
approved these changes
Aug 14, 2024
bkchr
approved these changes
Aug 14, 2024
Co-authored-by: Davide Galassi <davxy@datawok.net>
bkchr
approved these changes
Aug 28, 2024
davxy
approved these changes
Aug 29, 2024
Member
|
@LGLO can you please merge master again? |
Contributor
Author
|
@bkchr done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
starting_timestampfunction forSlottype.Integration
This is an addition of public function to a type, so integration should be seamless for idiomatic use of Rust.
Review Notes
Since
Slotis just a slot number, the it's starting timestamp depends onSlotDurationwhich is a parameter to the added function. This function can be seen as dual to existingfn from_timestamp.Because there is a potential for overflow, the return type is
Option.Q1: should I introduce tests for in this crate and add cases for both case: overflow (
None) and no overflow (Some)?Q2: How can I add labels? IMO they should be
T0-nodeandD0-easybut I cannot add them using GH interface.Checklist
Trequired)