forked from TrueCloudLab/frostfs-contract
[#42] common: Replace IRNode type and InnerRingInvoker func to ir.go file
Remove empty invoke.go source file. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0541d83cf4
commit
5d8c07b6e5
2 changed files with 17 additions and 21 deletions
|
@ -1,21 +0,0 @@
|
||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IRNode struct {
|
|
||||||
PublicKey []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// InnerRingInvoker returns public key of inner ring node that invoked contract.
|
|
||||||
func InnerRingInvoker(ir []IRNode) []byte {
|
|
||||||
for i := 0; i < len(ir); i++ {
|
|
||||||
node := ir[i]
|
|
||||||
if runtime.CheckWitness(node.PublicKey) {
|
|
||||||
return node.PublicKey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
17
common/ir.go
17
common/ir.go
|
@ -3,11 +3,28 @@ package common
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const irListMethod = "innerRingList"
|
const irListMethod = "innerRingList"
|
||||||
|
|
||||||
|
type IRNode struct {
|
||||||
|
PublicKey []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingInvoker returns public key of inner ring node that invoked contract.
|
||||||
|
func InnerRingInvoker(ir []IRNode) []byte {
|
||||||
|
for i := 0; i < len(ir); i++ {
|
||||||
|
node := ir[i]
|
||||||
|
if runtime.CheckWitness(node.PublicKey) {
|
||||||
|
return node.PublicKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// InnerRingList returns list of inner ring nodes through calling
|
// InnerRingList returns list of inner ring nodes through calling
|
||||||
// "innerRingList" method of smart contract.
|
// "innerRingList" method of smart contract.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue