2021-09-08 08:17:19 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
2021-09-08 08:17:19 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (d *Delete) setContainerID(v []byte) {
|
|
|
|
if v != nil {
|
2023-04-26 09:05:33 +00:00
|
|
|
d.ContainerIDValue = v
|
2021-09-08 08:17:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Delete) setSignature(v []byte) {
|
|
|
|
if v != nil {
|
2023-04-26 09:05:33 +00:00
|
|
|
d.SignatureValue = v
|
2021-09-08 08:17:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-01 08:55:06 +00:00
|
|
|
func (d *Delete) setPublicKey(v []byte) {
|
|
|
|
d.PublicKeyValue = v
|
|
|
|
}
|
|
|
|
|
2021-09-08 08:17:19 +00:00
|
|
|
func (d *Delete) setToken(v []byte) {
|
|
|
|
if v != nil {
|
2023-04-26 09:05:33 +00:00
|
|
|
d.TokenValue = v
|
2021-09-08 08:17:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var deleteFieldSetters = []func(*Delete, []byte){
|
|
|
|
// order on stack is reversed
|
|
|
|
(*Delete).setToken,
|
2023-06-01 08:55:06 +00:00
|
|
|
(*Delete).setPublicKey,
|
2021-09-08 08:17:19 +00:00
|
|
|
(*Delete).setSignature,
|
|
|
|
(*Delete).setContainerID,
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
// DeleteNotaryEvent is method name for container delete operations
|
|
|
|
// in `Container` contract. Is used as identificator for notary
|
|
|
|
// delete container requests.
|
|
|
|
DeleteNotaryEvent = "delete"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ParseDeleteNotary from NotaryEvent into container event structure.
|
|
|
|
func ParseDeleteNotary(ne event.NotaryEvent) (event.Event, error) {
|
|
|
|
var (
|
|
|
|
ev Delete
|
|
|
|
currentOp opcode.Opcode
|
|
|
|
)
|
|
|
|
|
|
|
|
fieldNum := 0
|
|
|
|
|
|
|
|
for _, op := range ne.Params() {
|
|
|
|
currentOp = op.Code()
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case opcode.PUSHDATA1 <= currentOp && currentOp <= opcode.PUSHDATA4:
|
|
|
|
if fieldNum == expectedItemNumDelete {
|
|
|
|
return nil, event.UnexpectedArgNumErr(DeleteNotaryEvent)
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteFieldSetters[fieldNum](&ev, op.Param())
|
|
|
|
fieldNum++
|
|
|
|
default:
|
|
|
|
return nil, event.UnexpectedOpcode(DeleteNotaryEvent, op.Code())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-26 09:05:33 +00:00
|
|
|
ev.NotaryRequestValue = ne.Raw()
|
2021-09-08 08:17:19 +00:00
|
|
|
|
|
|
|
return ev, nil
|
|
|
|
}
|