Summary
Implement the logic necessary to convert a Time to a Slot for a given network.
Description
Pallas provides a function to convert a slot to a date-time.
This is driven by the network parameters of a chain.
It is also possible to calculate an arbitrary slot# from a date-time.
Pallas does not implement this.
The requirement here is to implement:
|
pub fn time_to_slot(&self, _time: DateTime<Utc>) -> Option<u64> { |
By inspecting the code in Pallas that produces a date-time for a slot, and do the inverse operation.
There should be no need for IO as its calculated from known data for a network.
If the Datetime is earlier than the start time of the chain, it should return None.
Otherwise it returns the Slot that represents that date-time.