3

I want a transaction to only be valid for a certain period of time relative to some specified start time. I thought that maybe I could use Constraints.mustValidateIn (interval firstInterval $ firstInterval + 10000), but this has failed to validate. It seems that it does not matter what the upper bound is, because it always fails... unless its positive infinity. So this: Constraints.mustValidateIn (from $ firstInterval) always works.

In the docs, Constraints.mustValidateIn has a footnote specifying this: "@mustValidateIn r@ requires the transaction's time range to be contained in @r@."

So I guess what I am asking is what is a transactions time range? And can it be manipulated to fit this scenario?

Thanks!

1 Answer 1

2

I discovered this cool function named hull. Here is the function definition from the docs.

-- The function hull gives the smallest interval containing both the given intervals.
hull :: Ord a => Interval a -> Interval a -> Interval a
hull (Interval l1 h1) (Interval l2 h2) = Interval (min l1 l2) (max h1 h2)

I did not expect this to work any better than my previous attempts at specifying some range with an upper limit. But it did.

Here is my constraint now:

Constraints.mustValidateIn (hull (from $ firstInterval)(to $ firstInterval + 8000))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.