core: optimize contractCallEx
Provide script hash upon script load.
This commit is contained in:
parent
61edc8705e
commit
55ab7535be
2 changed files with 10 additions and 1 deletions
|
@ -442,7 +442,7 @@ func contractCallExInternal(ic *interop.Context, v *vm.VM, h []byte, method stac
|
||||||
return errors.New("disallowed method call")
|
return errors.New("disallowed method call")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v.LoadScript(cs.Script)
|
v.LoadScriptWithHash(cs.Script, u)
|
||||||
v.Estack().PushVal(args)
|
v.Estack().PushVal(args)
|
||||||
v.Estack().PushVal(method)
|
v.Estack().PushVal(method)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -268,6 +268,15 @@ func (v *VM) LoadScript(b []byte) {
|
||||||
v.istack.PushVal(ctx)
|
v.istack.PushVal(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadScriptWithHash if similar to the LoadScript method, but it also loads
|
||||||
|
// given script hash directly into the Context to avoid its recalculations. It's
|
||||||
|
// up to user of this function to make sure the script and hash match each other.
|
||||||
|
func (v *VM) LoadScriptWithHash(b []byte, hash util.Uint160) {
|
||||||
|
v.LoadScript(b)
|
||||||
|
ctx := v.Context()
|
||||||
|
ctx.scriptHash = hash
|
||||||
|
}
|
||||||
|
|
||||||
// Context returns the current executed context. Nil if there is no context,
|
// Context returns the current executed context. Nil if there is no context,
|
||||||
// which implies no program is loaded.
|
// which implies no program is loaded.
|
||||||
func (v *VM) Context() *Context {
|
func (v *VM) Context() *Context {
|
||||||
|
|
Loading…
Reference in a new issue