MCPcopy Create free account
hub / github.com/chain/Core / code

Method code

core/txbuilder/constraint.go:26–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26func (t timeConstraint) code() []byte {
27 if t.minTimeMS == 0 && t.maxTimeMS == 0 {
28 return []byte{byte(vm.OP_TRUE)}
29 }
30 builder := vmutil.NewBuilder()
31 if t.minTimeMS > 0 {
32 builder.AddOp(vm.OP_MINTIME).AddInt64(int64(t.minTimeMS)).AddOp(vm.OP_GREATERTHANOREQUAL)
33 }
34 if t.maxTimeMS > 0 {
35 if t.minTimeMS > 0 {
36 // Consume the boolean left by the "mintime" clause, failing
37 // immediately if it's false, so that the result of the
38 // "maxtime" clause below is really (mintime clause && maxtime
39 // clause).
40 builder.AddOp(vm.OP_VERIFY)
41 }
42 builder.AddOp(vm.OP_MAXTIME).AddInt64(int64(t.maxTimeMS)).AddOp(vm.OP_LESSTHANOREQUAL)
43 }
44 return builder.Program
45}
46
47// outpointConstraint requires the outputID (and therefore, the outpoint) being spent to equal the
48// given value.

Callers

nothing calls this directly

Calls 2

AddOpMethod · 0.95
AddInt64Method · 0.80

Tested by

no test coverage detected