mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-02-23 15:54:30 +00:00
core: remove ScriptHashGetter from interop context
We have VM inside the context, so don't need ScriptHashGetter anymore.
This commit is contained in:
parent
42736095a1
commit
c87e2262c3
4 changed files with 3 additions and 12 deletions
|
@ -35,7 +35,6 @@ type Context struct {
|
||||||
Notifications []state.NotificationEvent
|
Notifications []state.NotificationEvent
|
||||||
Log *zap.Logger
|
Log *zap.Logger
|
||||||
Invocations map[util.Uint160]int
|
Invocations map[util.Uint160]int
|
||||||
ScriptGetter vm.ScriptHashGetter
|
|
||||||
VM *vm.VM
|
VM *vm.VM
|
||||||
Functions [][]Function
|
Functions [][]Function
|
||||||
}
|
}
|
||||||
|
@ -176,7 +175,6 @@ func (ic *Context) SpawnVM() *vm.VM {
|
||||||
v := vm.NewWithTrigger(ic.Trigger)
|
v := vm.NewWithTrigger(ic.Trigger)
|
||||||
v.GasLimit = -1
|
v.GasLimit = -1
|
||||||
v.SyscallHandler = ic.SyscallHandler
|
v.SyscallHandler = ic.SyscallHandler
|
||||||
ic.ScriptGetter = v
|
|
||||||
ic.VM = v
|
ic.VM = v
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ import (
|
||||||
// for verifying in the interop context.
|
// for verifying in the interop context.
|
||||||
func CheckHashedWitness(ic *interop.Context, hash util.Uint160) (bool, error) {
|
func CheckHashedWitness(ic *interop.Context, hash util.Uint160) (bool, error) {
|
||||||
if tx, ok := ic.Container.(*transaction.Transaction); ok {
|
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")
|
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 {
|
for _, c := range tx.Signers {
|
||||||
if c.Account == hash {
|
if c.Account == hash {
|
||||||
if c.Scopes == transaction.Global {
|
if c.Scopes == transaction.Global {
|
||||||
|
|
|
@ -175,7 +175,7 @@ func (c *nep5TokenNative) transfer(ic *interop.Context, from, to util.Uint160, a
|
||||||
return errors.New("negative amount")
|
return errors.New("negative amount")
|
||||||
}
|
}
|
||||||
|
|
||||||
caller := ic.ScriptGetter.GetCallingScriptHash()
|
caller := ic.VM.GetCallingScriptHash()
|
||||||
if caller.Equals(util.Uint160{}) || !from.Equals(caller) {
|
if caller.Equals(util.Uint160{}) || !from.Equals(caller) {
|
||||||
ok, err := runtime.CheckHashedWitness(ic, from)
|
ok, err := runtime.CheckHashedWitness(ic, from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -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.
|
// StateMessage is a vm state message which could be used as additional info for example by cli.
|
||||||
type StateMessage string
|
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 (
|
const (
|
||||||
// MaxInvocationStackSize is the maximum size of an invocation stack.
|
// MaxInvocationStackSize is the maximum size of an invocation stack.
|
||||||
MaxInvocationStackSize = 1024
|
MaxInvocationStackSize = 1024
|
||||||
|
|
Loading…
Add table
Reference in a new issue