| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Tx.DepositPeriod
Synopsis
- newtype DepositPeriod = DepositPeriod {}
- fromNominalDiffTime :: MonadFail m => NominalDiffTime -> m DepositPeriod
- toChain :: DepositPeriod -> DepositPeriod
- fromChain :: DepositPeriod -> Either Text DepositPeriod
Documentation
newtype DepositPeriod Source #
A non-negative duration used as the deposit validity window.
Nodes within the same Head must configure identical values. Use
fromNominalDiffTime to create values of unknown sign.
NOTE: Zero is allowed, unlike ContestationPeriod: it means "no
margin", degenerate but workable, and it is what a sub-second period
truncates to. Sub-millisecond precision is not, see fromNominalDiffTime.
NOTE: FromJSON is deliberately newtype-derived and therefore total, for the
same reason as ContestationPeriod: it also decodes the persisted
event log. A configured period is validated at the configuration boundary
instead, see parseCardanoChainConfig.
Constructors
| DepositPeriod | |
Fields | |
Instances
fromNominalDiffTime :: MonadFail m => NominalDiffTime -> m DepositPeriod Source #
Create a DepositPeriod from a NominalDiffTime, accepting exactly the
durations that survive the on-chain encoding: a non-negative whole number of
milliseconds.
A negative duration would invert the deposit window. A finer-grained one would be written to the datum as a different period than the one configured, and the initiator would then not recognise its own head, consuming the seed and stranding the head output with no way to abort.
toChain :: DepositPeriod -> DepositPeriod Source #
Convert an off-chain deposit period to its on-chain representation.
fromChain :: DepositPeriod -> Either Text DepositPeriod Source #
Convert an on-chain deposit period to its off-chain representation. The on-chain representation is a signed number of milliseconds with no sign constraint, so an observed datum can carry a negative value, which would invert the deposit window; such a period is rejected. NOTE: Truncates to whole milliseconds.