From a98c221447020199aa7bf2c16b064726feae7238 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 7 Feb 2019 09:53:53 +1100 Subject: [PATCH] Add `new` fn to Slot and Epoch --- eth2/types/src/slot_epoch.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eth2/types/src/slot_epoch.rs b/eth2/types/src/slot_epoch.rs index 40b0c5e95..ccf8ec76d 100644 --- a/eth2/types/src/slot_epoch.rs +++ b/eth2/types/src/slot_epoch.rs @@ -241,6 +241,10 @@ impl_display!(Epoch); impl_ssz!(Epoch); impl Slot { + pub fn new(slot: u64) -> Slot { + Slot(slot) + } + pub fn epoch(&self, epoch_length: u64) -> Epoch { Epoch::from(self.0 / epoch_length) } @@ -251,6 +255,10 @@ impl Slot { } impl Epoch { + pub fn new(slot: u64) -> Epoch { + Epoch(slot) + } + pub fn start_slot(&self, epoch_length: u64) -> Slot { Slot::from(self.0.saturating_mul(epoch_length)) }