Skip to content

Commit

Permalink
CheckRuntimeVersion uses NewInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Aug 5, 2022
1 parent 7b15e83 commit f3a8cbf
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/runtime/wasmer/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,14 @@ func (in *Instance) UpdateRuntimeCode(code []byte) (err error) {
// CheckRuntimeVersion finds the runtime version by initiating a temporary
// runtime instance using the WASM code provided, and querying it.
func CheckRuntimeVersion(code []byte) (version runtime.Version, err error) {
wasmInstance, allocator, err := setupVM(code)
if err != nil {
return nil, fmt.Errorf("setting up VM: %w", err)
config := runtime.InstanceConfig{
LogLvl: log.DoNotChange,
}

ctx := &runtime.Context{
Allocator: allocator,
}
wasmInstance.SetContextData(ctx)

instance := Instance{
vm: wasmInstance,
ctx: ctx,
instance, err := NewInstance(code, config)
if err != nil {
return version, fmt.Errorf("creating runtime instance: %w", err)
}
defer instance.close()
defer instance.Stop()

version, err = instance.Version()
if err != nil {
Expand Down

0 comments on commit f3a8cbf

Please sign in to comment.