2020-09-02 13:05:31 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
|
|
|
|
2024-12-05 08:52:30 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/container"
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
2022-07-28 16:22:32 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
2021-09-08 08:17:19 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
2020-09-02 13:05:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Delete structure of container.Delete notification from morph chain.
|
|
|
|
type Delete struct {
|
2023-04-26 09:05:33 +00:00
|
|
|
ContainerIDValue []byte
|
|
|
|
SignatureValue []byte
|
|
|
|
TokenValue []byte
|
2023-06-01 08:55:06 +00:00
|
|
|
PublicKeyValue []byte
|
2021-09-08 08:17:19 +00:00
|
|
|
|
|
|
|
// For notary notifications only.
|
|
|
|
// Contains raw transactions of notary request.
|
2023-04-26 09:05:33 +00:00
|
|
|
NotaryRequestValue *payload.P2PNotaryRequest
|
2020-09-02 13:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MorphEvent implements Neo:Morph Event interface.
|
|
|
|
func (Delete) MorphEvent() {}
|
|
|
|
|
2021-08-25 10:51:15 +00:00
|
|
|
// ContainerID is a marshalled container structure, defined in API.
|
2023-04-26 09:05:33 +00:00
|
|
|
func (d Delete) ContainerID() []byte { return d.ContainerIDValue }
|
2020-09-02 13:05:31 +00:00
|
|
|
|
|
|
|
// Signature of marshalled container by container owner.
|
2023-04-26 09:05:33 +00:00
|
|
|
func (d Delete) Signature() []byte { return d.SignatureValue }
|
2020-09-02 13:05:31 +00:00
|
|
|
|
2021-05-26 10:55:58 +00:00
|
|
|
// SessionToken returns binary token of the session
|
|
|
|
// within which the eACL was set.
|
|
|
|
func (d Delete) SessionToken() []byte {
|
2023-04-26 09:05:33 +00:00
|
|
|
return d.TokenValue
|
2021-05-26 10:55:58 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 08:17:19 +00:00
|
|
|
// NotaryRequest returns raw notary request if notification
|
|
|
|
// was received via notary service. Otherwise, returns nil.
|
|
|
|
func (d Delete) NotaryRequest() *payload.P2PNotaryRequest {
|
2023-04-26 09:05:33 +00:00
|
|
|
return d.NotaryRequestValue
|
2021-09-08 08:17:19 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 08:55:06 +00:00
|
|
|
const expectedItemNumDelete = 4
|
2021-09-08 08:17:19 +00:00
|
|
|
|
2022-08-11 13:24:26 +00:00
|
|
|
// DeleteSuccess structures notification event of successful container removal
|
|
|
|
// thrown by Container contract.
|
|
|
|
type DeleteSuccess struct {
|
|
|
|
// Identifier of the removed container.
|
|
|
|
ID cid.ID
|
|
|
|
}
|
|
|
|
|
|
|
|
// MorphEvent implements Neo:Morph Event interface.
|
|
|
|
func (DeleteSuccess) MorphEvent() {}
|
|
|
|
|
|
|
|
// ParseDeleteSuccess decodes notification event thrown by Container contract into
|
|
|
|
// DeleteSuccess and returns it as event.Event.
|
|
|
|
func ParseDeleteSuccess(e *state.ContainedNotificationEvent) (event.Event, error) {
|
2024-12-05 08:52:30 +00:00
|
|
|
var dse container.DeleteSuccessEvent
|
|
|
|
if err := dse.FromStackItem(e.Item); err != nil {
|
|
|
|
return nil, fmt.Errorf("parse container.DeleteSuccessEvent: %w", err)
|
2022-08-11 13:24:26 +00:00
|
|
|
}
|
|
|
|
|
2024-12-05 08:52:30 +00:00
|
|
|
var cnr cid.ID
|
|
|
|
cnr.SetSHA256(dse.ContainerID)
|
|
|
|
return DeleteSuccess{
|
|
|
|
ID: cnr,
|
|
|
|
}, nil
|
2022-08-11 13:24:26 +00:00
|
|
|
}
|