package container

import (
	"github.com/nspcc-dev/neo-go/pkg/network/payload"
)

// SetEACL represents structure of notification about
// modified eACL table coming from FrostFS Container contract.
type SetEACL struct {
	TableValue     []byte
	SignatureValue []byte
	PublicKeyValue []byte
	TokenValue     []byte

	// For notary notifications only.
	// Contains raw transactions of notary request.
	NotaryRequestValue *payload.P2PNotaryRequest
}

// MorphEvent implements Neo:Morph Event interface.
func (SetEACL) MorphEvent() {}

// Table returns returns eACL table in a binary FrostFS API format.
func (x SetEACL) Table() []byte {
	return x.TableValue
}

// Signature returns signature of the binary table.
func (x SetEACL) Signature() []byte {
	return x.SignatureValue
}

// PublicKey returns public keys of container
// owner in a binary format.
func (x SetEACL) PublicKey() []byte {
	return x.PublicKeyValue
}

// SessionToken returns binary token of the session
// within which the eACL was set.
func (x SetEACL) SessionToken() []byte {
	return x.TokenValue
}

// NotaryRequest returns raw notary request if notification
// was received via notary service. Otherwise, returns nil.
func (x SetEACL) NotaryRequest() *payload.P2PNotaryRequest {
	return x.NotaryRequestValue
}

const expectedItemNumEACL = 4