consensus-slots: cleanup SlotDuration config (#10878)

* consensus-slots: cleanup the SlotDuration config

* fix tests

* address review comments
This commit is contained in:
André Silva
2022-02-22 19:39:16 +00:00
committed by GitHub
parent f00404bfd6
commit 2561e11ed7
19 changed files with 161 additions and 191 deletions
+7 -1
View File
@@ -42,10 +42,16 @@ impl Timestamp {
}
/// Returns `self` as [`Duration`].
pub fn as_duration(self) -> Duration {
pub const fn as_duration(self) -> Duration {
Duration::from_millis(self.0)
}
/// Returns `self` as a `u64` representing the elapsed time since the UNIX_EPOCH in
/// milliseconds.
pub const fn as_millis(&self) -> u64 {
self.0
}
/// Checked subtraction that returns `None` on an underflow.
pub fn checked_sub(self, other: Self) -> Option<Self> {
self.0.checked_sub(other.0).map(Self)