-
Notifications
You must be signed in to change notification settings - Fork 177
/
runtime.go
46 lines (36 loc) · 979 Bytes
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package environment
import (
cadenceRuntime "github.com/onflow/cadence/runtime"
"github.com/onflow/flow-go/fvm/runtime"
)
type RuntimeParams struct {
runtime.ReusableCadenceRuntimePool
}
func DefaultRuntimeParams() RuntimeParams {
return RuntimeParams{
ReusableCadenceRuntimePool: runtime.NewReusableCadenceRuntimePool(
0,
cadenceRuntime.Config{}),
}
}
// Runtime expose the cadence runtime to the rest of the envionment package.
type Runtime struct {
RuntimeParams
env Environment
}
func NewRuntime(params RuntimeParams) *Runtime {
return &Runtime{
RuntimeParams: params,
}
}
func (runtime *Runtime) SetEnvironment(env Environment) {
runtime.env = env
}
func (runtime *Runtime) BorrowCadenceRuntime() *runtime.ReusableCadenceRuntime {
return runtime.ReusableCadenceRuntimePool.Borrow(runtime.env)
}
func (runtime *Runtime) ReturnCadenceRuntime(
reusable *runtime.ReusableCadenceRuntime,
) {
runtime.ReusableCadenceRuntimePool.Return(reusable)
}