Module

Ctl.Internal.Types.Interval

#AbsTime

newtype AbsTime

Absolute time relative to System Start, not UNIX epoch. Treat as Milliseconds

Constructors

Instances

#Closure

type Closure = Boolean

Whether a bound is inclusive or not.

#Extended

data Extended a

A set extended with a positive and negative infinity.

Constructors

Instances

#Interval

data Interval a

An abstraction for Interval, it restricts the creation of intervals to the only ones that we can use in practice: [a,b+1) , [-infinity,b+1), [a,infinity], [-infinity,infinity], empty.

Constructors

Instances

#LowerBound

data LowerBound a

The lower bound of an interval.

Constructors

Instances

#ModTime

newtype ModTime

Any leftover time from using mod when dividing my slot length. Treat as Milliseconds

Constructors

Instances

#OnchainPOSIXTimeRange

newtype OnchainPOSIXTimeRange

A newtype wrapper over POSIXTimeRange to represent the on-chain version of an off-chain POSIXTimeRange. In particular, there are a few steps in conversion:

  1. POSIXTimeRange -> SlotRange
  2. SlotRange -> TransactionValidity
  3. TransactionValidity -> OnchainPOSIXTimeRange OnchainPOSIXTimeRange is intended to equal the validity range found in the on-chain ScriptContext

Constructors

Instances

#POSIXTimeRange

type POSIXTimeRange = Interval POSIXTime

An Interval of POSIXTimes.

#RelSlot

newtype RelSlot

Relative slot of an Slot within an EraSummary

Constructors

Instances

#RelTime

newtype RelTime

Relative time to the start of an EraSummary. Contract this to Ogmios.QueryM.RelativeTime which is usually relative to system start. Treat as Milliseconds

Constructors

Instances

#SlotRange

#UpperBound

data UpperBound a

The upper bound of an interval.

Constructors

Instances

#after

after :: forall (a :: Type). Ord a => a -> Interval a -> Boolean

Check if a value is later than the end of a Interval.

#always

always :: forall (a :: Type). Ord a => Interval a

An Interval that covers every slot, represented as [-infinity,infinity]

#before

before :: forall (a :: Type). Ord a => a -> Interval a -> Boolean

Check if a value is earlier than the beginning of an Interval.

#contains

contains :: forall (a :: Type). Ord a => Interval a -> Interval a -> Boolean

a contains b is true if the Interval b is entirely contained in a. That is, acontainsbif for every entrys, ifmember s bthenmember s a`.

#findSlotEraSummary

findSlotEraSummary :: EraSummaries -> Slot -> Either SlotToPosixTimeError EraSummary

Finds the EraSummary an Slot lies inside (if any).

#findTimeEraSummary

findTimeEraSummary :: EraSummaries -> AbsTime -> Either PosixTimeToSlotError EraSummary

Finds the EraSummary an AbsTime lies inside (if any).

#from

from :: forall (a :: Type). Ord a => a -> Interval a

from a is an Interval that includes all values that are greater than or equal to a, represented as [a,infinity].

#getSlotLength

getSlotLength :: EraSummary -> Number

Get SlotLength in Milliseconds

#hull

hull :: forall (a :: Type). Ord a => Interval a -> Interval a -> Interval a

hull a b is the smallest interval containing a and b between our limited universe of intervals.

#intersection

intersection :: forall (a :: Type). Ord a => Interval a -> Interval a -> Interval a

intersection a b is the largest interval that is contained in a and in b, if it exists.

#isEmpty

isEmpty :: forall (a :: Type). Ord a => Interval a -> Boolean

Check if an Interval is empty.

#isEmpty'

isEmpty' :: forall (a :: Type). Ord a => Warn (Text "Deprecated, use `isEmpty` instead") => Interval a -> Boolean

#lowerBound

lowerBound :: forall (a :: Type). a -> LowerBound a

#maxSlot

maxSlot :: Slot

Maximum slot (u64)

#mkFiniteInterval

mkFiniteInterval :: forall (a :: Type). Ord a => a -> a -> Interval a

mkFiniteInterval a b construct the interval [a,b+1)

#member

member :: forall (a :: Type). Ord a => a -> Interval a -> Boolean

Check whether a value is in an interval.

#never

never :: forall (a :: Type). Ord a => Interval a

An Interval that is empty, represented as [infinity,-infinity]

#overlaps

overlaps :: forall (a :: Type). Ord a => Interval a -> Interval a -> Boolean

Check whether two intervals overlap, that is, whether there is a value that is a member of both intervals.

#overlaps'

overlaps' :: forall (a :: Type). Warn (Text "Deprecated, use `overlaps` instead") => Ord a => Interval a -> Interval a -> Boolean

Check whether two intervals overlap, that is, whether there is a value that is a member of both intervals.

#posixTimeRangeToSlotRange

posixTimeRangeToSlotRange :: EraSummaries -> SystemStart -> POSIXTimeRange -> Either PosixTimeToSlotError SlotRange

Converts a POSIXTimeRange to SlotRange given an EraSummaries and SystemStart queried from Ogmios.

#posixTimeRangeToTransactionValidity

posixTimeRangeToTransactionValidity :: EraSummaries -> SystemStart -> POSIXTimeRange -> Either PosixTimeToSlotError TransactionValiditySlot

Converts a POSIXTimeRange to a transaction validity interval via a SlotRange to be used when building a CSL transaction body

#posixTimeToSlot

posixTimeToSlot :: EraSummaries -> SystemStart -> POSIXTime -> Either PosixTimeToSlotError Slot

Converts a POSIXTime to Slot given an EraSummaries and SystemStart queried from Ogmios.

#explainPosixTimeToSlotError

#singleton

singleton :: forall (a :: Type). Ord a => Semiring a => a -> Interval a

singleton a is an Interval that contains just a, represented as [a,a+1).

#slotRangeToPosixTimeRange

slotRangeToPosixTimeRange :: EraSummaries -> SystemStart -> SlotRange -> Either SlotToPosixTimeError POSIXTimeRange

Converts a SlotRange to POSIXTimeRange given an EraSummaries and SystemStart queried from Ogmios.

#slotToPosixTime

slotToPosixTime :: EraSummaries -> SystemStart -> Slot -> Either SlotToPosixTimeError POSIXTime

Converts a CSL (Absolute) Slot (Unsigned Integer) to POSIXTime which is time elapsed from January 1, 1970 (midnight UTC/GMT). We obtain this By converting Slot to AbsTime which is time relative to some System Start, then add any excess for a UNIX Epoch time. Recall that POSIXTime is in milliseconds for Protocol Version >= 6.

#strictLowerBound

strictLowerBound :: forall (a :: Type). a -> LowerBound a

#strictUpperBound

strictUpperBound :: forall (a :: Type). a -> UpperBound a

#to

to :: forall (a :: Type). Ord a => a -> Interval a

to a is an Interval that includes all values that are smaller than or equal to a, represented as [-infinity,a+1).

#toOnchainPosixTimeRange

toOnchainPosixTimeRange :: EraSummaries -> SystemStart -> POSIXTimeRange -> Either ToOnChainPosixTimeRangeError OnchainPOSIXTimeRange

Create an OnchainPOSIXTimeRange to do a round trip from an off-chain POSIXTimeRange as follows:

  1. POSIXTimeRange -> SlotRange
  2. SlotRange -> TransactionValidity
  3. TransactionValidity -> OnchainPOSIXTimeRange OnchainPOSIXTimeRange is intended to equal the validity range found in the on-chain ScriptContext

#upperBound

upperBound :: forall (a :: Type). a -> UpperBound a

#genFiniteInterval

genFiniteInterval :: forall (a :: Type). Ord a => Gen a -> Gen (Interval a)

those accept a generator since we want to use them for Positive Integers in tests

#genLowerRay

genLowerRay :: forall (a :: Type). Ord a => Gen a -> Gen (Interval a)

#genUpperRay

genUpperRay :: forall (a :: Type). Ord a => Gen a -> Gen (Interval a)

Modules