polkadot-sdk icon indicating copy to clipboard operation
polkadot-sdk copied to clipboard

Add an utility function to get the first timestamp of a slot

Open LGLO opened this issue 6 months ago • 1 comments

Description

Add starting_timestamp function for Slot type.

Integration

This is an addition of public function to a type, so integration should be seamless for idiomatic use of Rust.

Review Notes

Since Slot is just a slot number, the it's starting timestamp depends on SlotDuration which is a parameter to the added function. This function can be seen as dual to existing fn 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-node and D0-easy but I cannot add them using GH interface.

Checklist

  • [x] My PR includes a detailed description as outlined in the "Description" and its two subsections above.
  • [ ] My PR follows the labeling requirements of this project (at minimum one label for T required)
    • External contributors: ask maintainers to put the right label on your PR.
  • [ ] I have made corresponding changes to the documentation (if applicable)
  • [ ] I have added tests that prove my fix is effective or that my feature works (if applicable)

LGLO avatar Aug 12 '24 08:08 LGLO