mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
vm: hide GetContextScriptHash() method
After adding ScriptHashGetter interface to vm, there's no need in GetContextScriptHash() to be exported.
This commit is contained in:
parent
73167999cc
commit
5ece9922c1
5 changed files with 13 additions and 13 deletions
|
@ -540,7 +540,7 @@ func contractMigrate(ic *interop.Context, v *vm.VM) error {
|
|||
return err
|
||||
}
|
||||
if contract.HasStorage() {
|
||||
hash := v.GetContextScriptHash(0)
|
||||
hash := v.GetCurrentScriptHash()
|
||||
siMap, err := ic.DAO.GetStorageItems(hash)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -292,7 +292,7 @@ func runtimeNotify(ic *interop.Context, v *vm.VM) error {
|
|||
if err != nil {
|
||||
item = vm.NewByteArrayItem([]byte(fmt.Sprintf("bad notification: %v", err)))
|
||||
}
|
||||
ne := state.NotificationEvent{ScriptHash: v.GetContextScriptHash(0), Item: item}
|
||||
ne := state.NotificationEvent{ScriptHash: v.GetCurrentScriptHash(), Item: item}
|
||||
ic.Notifications = append(ic.Notifications, ne)
|
||||
return nil
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ func runtimeNotify(ic *interop.Context, v *vm.VM) error {
|
|||
func runtimeLog(ic *interop.Context, v *vm.VM) error {
|
||||
msg := fmt.Sprintf("%q", v.Estack().Pop().Bytes())
|
||||
ic.Log.Info("runtime log",
|
||||
zap.Stringer("script", v.GetContextScriptHash(0)),
|
||||
zap.Stringer("script", v.GetCurrentScriptHash()),
|
||||
zap.String("logs", msg))
|
||||
return nil
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ func storageGet(ic *interop.Context, v *vm.VM) error {
|
|||
// storageGetContext returns storage context (scripthash).
|
||||
func storageGetContext(ic *interop.Context, v *vm.VM) error {
|
||||
sc := &StorageContext{
|
||||
ScriptHash: v.GetContextScriptHash(0),
|
||||
ScriptHash: v.GetCurrentScriptHash(),
|
||||
ReadOnly: false,
|
||||
}
|
||||
v.Estack().PushVal(vm.NewInteropItem(sc))
|
||||
|
@ -393,7 +393,7 @@ func storageGetContext(ic *interop.Context, v *vm.VM) error {
|
|||
// storageGetReadOnlyContext returns read-only context (scripthash).
|
||||
func storageGetReadOnlyContext(ic *interop.Context, v *vm.VM) error {
|
||||
sc := &StorageContext{
|
||||
ScriptHash: v.GetContextScriptHash(0),
|
||||
ScriptHash: v.GetCurrentScriptHash(),
|
||||
ReadOnly: true,
|
||||
}
|
||||
v.Estack().PushVal(vm.NewInteropItem(sc))
|
||||
|
@ -475,7 +475,7 @@ func contractDestroy(ic *interop.Context, v *vm.VM) error {
|
|||
if ic.Trigger != trigger.Application {
|
||||
return errors.New("can't destroy contract when not triggered by application")
|
||||
}
|
||||
hash := v.GetContextScriptHash(0)
|
||||
hash := v.GetCurrentScriptHash()
|
||||
cs, err := ic.DAO.GetContractState(hash)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
|
@ -69,7 +69,7 @@ func (cs *Contracts) GetNativeInterop(ic *interop.Context) func(uint32) *vm.Inte
|
|||
// getNativeInterop returns native contract interop.
|
||||
func getNativeInterop(ic *interop.Context, c interop.Contract) func(v *vm.VM) error {
|
||||
return func(v *vm.VM) error {
|
||||
h := v.GetContextScriptHash(0)
|
||||
h := v.GetCurrentScriptHash()
|
||||
if !h.Equals(c.Metadata().Hash) {
|
||||
return errors.New("invalid hash")
|
||||
}
|
||||
|
|
|
@ -223,9 +223,9 @@ func (c *Context) String() string {
|
|||
return "execution context"
|
||||
}
|
||||
|
||||
// GetContextScriptHash returns script hash of the invocation stack element
|
||||
// getContextScriptHash returns script hash of the invocation stack element
|
||||
// number n.
|
||||
func (v *VM) GetContextScriptHash(n int) util.Uint160 {
|
||||
func (v *VM) getContextScriptHash(n int) util.Uint160 {
|
||||
element := v.Istack().Peek(n)
|
||||
if element == nil {
|
||||
return util.Uint160{}
|
||||
|
@ -238,7 +238,7 @@ func (v *VM) GetContextScriptHash(n int) util.Uint160 {
|
|||
// PushContextScriptHash pushes to evaluation stack the script hash of the
|
||||
// invocation stack element number n.
|
||||
func (v *VM) PushContextScriptHash(n int) error {
|
||||
h := v.GetContextScriptHash(n)
|
||||
h := v.getContextScriptHash(n)
|
||||
v.Estack().PushVal(h.BytesBE())
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1537,15 +1537,15 @@ func (v *VM) bytesToPublicKey(b []byte) *keys.PublicKey {
|
|||
|
||||
// GetCallingScriptHash implements ScriptHashGetter interface
|
||||
func (v *VM) GetCallingScriptHash() util.Uint160 {
|
||||
return v.GetContextScriptHash(1)
|
||||
return v.getContextScriptHash(1)
|
||||
}
|
||||
|
||||
// GetEntryScriptHash implements ScriptHashGetter interface
|
||||
func (v *VM) GetEntryScriptHash() util.Uint160 {
|
||||
return v.GetContextScriptHash(v.Istack().Len() - 1)
|
||||
return v.getContextScriptHash(v.Istack().Len() - 1)
|
||||
}
|
||||
|
||||
// GetCurrentScriptHash implements ScriptHashGetter interface
|
||||
func (v *VM) GetCurrentScriptHash() util.Uint160 {
|
||||
return v.GetContextScriptHash(0)
|
||||
return v.getContextScriptHash(0)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue