forked from TrueCloudLab/neoneo-go
core: provide key recovery interops only if neox is enabled
This commit is contained in:
parent
b5fb63d091
commit
9ee9cb8e39
1 changed files with 15 additions and 2 deletions
|
@ -52,6 +52,9 @@ func (ic *interopContext) SpawnVM() *vm.VM {
|
||||||
})
|
})
|
||||||
vm.RegisterInteropGetter(ic.getSystemInterop)
|
vm.RegisterInteropGetter(ic.getSystemInterop)
|
||||||
vm.RegisterInteropGetter(ic.getNeoInterop)
|
vm.RegisterInteropGetter(ic.getNeoInterop)
|
||||||
|
if ic.bc != nil && ic.bc.GetConfig().EnableStateRoot {
|
||||||
|
vm.RegisterInteropGetter(ic.getNeoxInterop)
|
||||||
|
}
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +80,12 @@ func (ic *interopContext) getNeoInterop(id uint32) *vm.InteropFuncPrice {
|
||||||
return ic.getInteropFromSlice(id, neoInterops)
|
return ic.getInteropFromSlice(id, neoInterops)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getNeoxInterop returns matching interop function from the NeoX extension
|
||||||
|
// for a given id in the current context.
|
||||||
|
func (ic *interopContext) getNeoxInterop(id uint32) *vm.InteropFuncPrice {
|
||||||
|
return ic.getInteropFromSlice(id, neoxInterops)
|
||||||
|
}
|
||||||
|
|
||||||
// getInteropFromSlice returns matching interop function from the given slice of
|
// getInteropFromSlice returns matching interop function from the given slice of
|
||||||
// interop functions in the current context.
|
// interop functions in the current context.
|
||||||
func (ic *interopContext) getInteropFromSlice(id uint32, slice []interopedFunction) *vm.InteropFuncPrice {
|
func (ic *interopContext) getInteropFromSlice(id uint32, slice []interopedFunction) *vm.InteropFuncPrice {
|
||||||
|
@ -166,8 +175,6 @@ var neoInterops = []interopedFunction{
|
||||||
{Name: "Neo.Contract.GetStorageContext", Func: (*interopContext).contractGetStorageContext, Price: 1},
|
{Name: "Neo.Contract.GetStorageContext", Func: (*interopContext).contractGetStorageContext, Price: 1},
|
||||||
{Name: "Neo.Contract.IsPayable", Func: (*interopContext).contractIsPayable, Price: 1},
|
{Name: "Neo.Contract.IsPayable", Func: (*interopContext).contractIsPayable, Price: 1},
|
||||||
{Name: "Neo.Contract.Migrate", Func: (*interopContext).contractMigrate, Price: 0},
|
{Name: "Neo.Contract.Migrate", Func: (*interopContext).contractMigrate, Price: 0},
|
||||||
{Name: "Neo.Cryptography.Secp256k1Recover", Func: (*interopContext).secp256k1Recover, Price: 100},
|
|
||||||
{Name: "Neo.Cryptography.Secp256r1Recover", Func: (*interopContext).secp256r1Recover, Price: 100},
|
|
||||||
{Name: "Neo.Enumerator.Concat", Func: (*interopContext).enumeratorConcat, Price: 1},
|
{Name: "Neo.Enumerator.Concat", Func: (*interopContext).enumeratorConcat, Price: 1},
|
||||||
{Name: "Neo.Enumerator.Create", Func: (*interopContext).enumeratorCreate, Price: 1},
|
{Name: "Neo.Enumerator.Create", Func: (*interopContext).enumeratorCreate, Price: 1},
|
||||||
{Name: "Neo.Enumerator.Next", Func: (*interopContext).enumeratorNext, Price: 1},
|
{Name: "Neo.Enumerator.Next", Func: (*interopContext).enumeratorNext, Price: 1},
|
||||||
|
@ -278,6 +285,11 @@ var neoInterops = []interopedFunction{
|
||||||
{Name: "AntShares.Transaction.GetType", Func: (*interopContext).txGetType, Price: 1},
|
{Name: "AntShares.Transaction.GetType", Func: (*interopContext).txGetType, Price: 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var neoxInterops = []interopedFunction{
|
||||||
|
{Name: "Neo.Cryptography.Secp256k1Recover", Func: (*interopContext).secp256k1Recover, Price: 100},
|
||||||
|
{Name: "Neo.Cryptography.Secp256r1Recover", Func: (*interopContext).secp256r1Recover, Price: 100},
|
||||||
|
}
|
||||||
|
|
||||||
// initIDinInteropsSlice initializes IDs from names in one given
|
// initIDinInteropsSlice initializes IDs from names in one given
|
||||||
// interopedFunction slice and then sorts it.
|
// interopedFunction slice and then sorts it.
|
||||||
func initIDinInteropsSlice(iops []interopedFunction) {
|
func initIDinInteropsSlice(iops []interopedFunction) {
|
||||||
|
@ -293,4 +305,5 @@ func initIDinInteropsSlice(iops []interopedFunction) {
|
||||||
func init() {
|
func init() {
|
||||||
initIDinInteropsSlice(systemInterops)
|
initIDinInteropsSlice(systemInterops)
|
||||||
initIDinInteropsSlice(neoInterops)
|
initIDinInteropsSlice(neoInterops)
|
||||||
|
initIDinInteropsSlice(neoxInterops)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue