hydra-tx
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Tx.DepositPeriod

Synopsis

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.

Instances

Instances details
FromJSON DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Methods

parseJSON :: Value -> Parser DepositPeriod

parseJSONList :: Value -> Parser [DepositPeriod]

omittedField :: Maybe DepositPeriod

ToJSON DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Generic DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Associated Types

type Rep DepositPeriod :: Type -> Type Source #

Num DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Read DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Real DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Show DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

FromCBOR DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Methods

fromCBOR :: Decoder s DepositPeriod

label :: Proxy DepositPeriod -> Text

ToCBOR DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Methods

toCBOR :: DepositPeriod -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy DepositPeriod -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [DepositPeriod] -> Size

Eq DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

Ord DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

type Rep DepositPeriod Source # 
Instance details

Defined in Hydra.Tx.DepositPeriod

type Rep DepositPeriod = D1 ('MetaData "DepositPeriod" "Hydra.Tx.DepositPeriod" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'True) (C1 ('MetaCons "DepositPeriod" 'PrefixI 'True) (S1 ('MetaSel ('Just "toNominalDiffTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NominalDiffTime)))

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.