frostfs-node/pkg/morph/event/container/eacl_notary.go
Alex Vanin 20de74a505 Rename package name
Due to source code relocation from GitHub.

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-03-07 16:38:26 +03:00

75 lines
1.5 KiB
Go

package container
import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
)
func (x *SetEACL) setTable(v []byte) {
if v != nil {
x.table = v
}
}
func (x *SetEACL) setSignature(v []byte) {
if v != nil {
x.signature = v
}
}
func (x *SetEACL) setPublicKey(v []byte) {
if v != nil {
x.publicKey = v
}
}
func (x *SetEACL) setToken(v []byte) {
if v != nil {
x.token = v
}
}
var setEACLFieldSetters = []func(*SetEACL, []byte){
// order on stack is reversed
(*SetEACL).setToken,
(*SetEACL).setPublicKey,
(*SetEACL).setSignature,
(*SetEACL).setTable,
}
const (
// SetEACLNotaryEvent is method name for container EACL operations
// in `Container` contract. Is used as identificator for notary
// EACL changing requests.
SetEACLNotaryEvent = "setEACL"
)
// ParseSetEACLNotary from NotaryEvent into container event structure.
func ParseSetEACLNotary(ne event.NotaryEvent) (event.Event, error) {
var (
ev SetEACL
currentOp opcode.Opcode
)
fieldNum := 0
for _, op := range ne.Params() {
currentOp = op.Code()
switch {
case opcode.PUSHDATA1 <= currentOp && currentOp <= opcode.PUSHDATA4:
if fieldNum == expectedItemNumEACL {
return nil, event.UnexpectedArgNumErr(SetEACLNotaryEvent)
}
setEACLFieldSetters[fieldNum](&ev, op.Param())
fieldNum++
default:
return nil, event.UnexpectedOpcode(SetEACLNotaryEvent, op.Code())
}
}
ev.notaryRequest = ne.Raw()
return ev, nil
}