pub struct QuantSpec {
pub unit: ChainEpoch,
pub offset: ChainEpoch,
}Expand description
A spec for epoch quantization.
Fields§
§unit: ChainEpochThe unit of quantization
offset: ChainEpochThe offset from zero from which to base the modulus
Implementations§
Source§impl QuantSpec
impl QuantSpec
Sourcepub fn quantize_up(&self, epoch: ChainEpoch) -> ChainEpoch
pub fn quantize_up(&self, epoch: ChainEpoch) -> ChainEpoch
Rounds epoch to the nearest exact multiple of the quantization unit offset by
offset % unit, rounding up.
This function is equivalent to unit * ceil(epoch - (offset % unit) / unit) + (offsetSeed % unit)
with the variables/operations over real numbers instead of ints.
Precondition: unit >= 0
pub fn quantize_down(&self, epoch: ChainEpoch) -> ChainEpoch
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QuantSpec
impl RefUnwindSafe for QuantSpec
impl Send for QuantSpec
impl Sync for QuantSpec
impl Unpin for QuantSpec
impl UnwindSafe for QuantSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more