core: remove ScriptHashGetter from interop context

We have VM inside the context, so don't need ScriptHashGetter anymore.
This commit is contained in:
Anna Shaleva 2020-08-07 16:58:09 +03:00
parent 42736095a1
commit c87e2262c3
4 changed files with 3 additions and 12 deletions

View file

@ -35,7 +35,6 @@ type Context struct {
Notifications []state.NotificationEvent
Log *zap.Logger
Invocations map[util.Uint160]int
ScriptGetter vm.ScriptHashGetter
VM *vm.VM
Functions [][]Function
}
@ -176,7 +175,6 @@ func (ic *Context) SpawnVM() *vm.VM {
v := vm.NewWithTrigger(ic.Trigger)
v.GasLimit = -1
v.SyscallHandler = ic.SyscallHandler
ic.ScriptGetter = v
ic.VM = v
return v
}

View file

@ -16,13 +16,13 @@ import (
// for verifying in the interop context.
func CheckHashedWitness(ic *interop.Context, hash util.Uint160) (bool, error) {
if tx, ok := ic.Container.(*transaction.Transaction); ok {
return checkScope(ic.DAO, tx, ic.ScriptGetter, hash)
return checkScope(ic.DAO, tx, ic.VM, hash)
}
return false, errors.New("script container is not a transaction")
}
func checkScope(d dao.DAO, tx *transaction.Transaction, v vm.ScriptHashGetter, hash util.Uint160) (bool, error) {
func checkScope(d dao.DAO, tx *transaction.Transaction, v *vm.VM, hash util.Uint160) (bool, error) {
for _, c := range tx.Signers {
if c.Account == hash {
if c.Scopes == transaction.Global {

View file

@ -175,7 +175,7 @@ func (c *nep5TokenNative) transfer(ic *interop.Context, from, to util.Uint160, a
return errors.New("negative amount")
}
caller := ic.ScriptGetter.GetCallingScriptHash()
caller := ic.VM.GetCallingScriptHash()
if caller.Equals(util.Uint160{}) || !from.Equals(caller) {
ok, err := runtime.CheckHashedWitness(ic, from)
if err != nil {

View file

@ -40,13 +40,6 @@ func newError(ip int, op opcode.Opcode, err interface{}) *errorAtInstruct {
// StateMessage is a vm state message which could be used as additional info for example by cli.
type StateMessage string
// ScriptHashGetter defines an interface for getting calling, entry and current script hashes.
type ScriptHashGetter interface {
GetCallingScriptHash() util.Uint160
GetEntryScriptHash() util.Uint160
GetCurrentScriptHash() util.Uint160
}
const (
// MaxInvocationStackSize is the maximum size of an invocation stack.
MaxInvocationStackSize = 1024