diff --git a/pkg/vm/stackitem/item.go b/pkg/vm/stackitem/item.go index c20701b50..a737dff29 100644 --- a/pkg/vm/stackitem/item.go +++ b/pkg/vm/stackitem/item.go @@ -871,6 +871,18 @@ func NewPointer(pos int, script []byte) *Pointer { } } +// NewPointerWithHash returns new pointer on the specified position of the +// specified script. It differs from NewPointer in that the script hash is being +// passed explicitly to save on hash calculcation. This hash is then being used +// for pointer comparisons. +func NewPointerWithHash(pos int, script []byte, h util.Uint160) *Pointer { + return &Pointer{ + pos: pos, + script: script, + hash: h, + } +} + // String implements Item interface. func (p *Pointer) String() string { return "Pointer" @@ -1079,7 +1091,7 @@ func deepCopy(item Item, seen map[Item]Item) Item { case *Bool: return NewBool(it.value) case *Pointer: - return NewPointer(it.pos, it.script) + return NewPointerWithHash(it.pos, it.script, it.hash) case *Interop: return NewInterop(it.value) default: diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index af9cfff6e..92965c80e 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -535,7 +535,7 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro case opcode.PUSHA: n := v.getJumpOffset(ctx, parameter) - ptr := stackitem.NewPointer(n, ctx.prog) + ptr := stackitem.NewPointerWithHash(n, ctx.prog, ctx.ScriptHash()) v.estack.PushVal(ptr) case opcode.PUSHNULL: