2022-12-23 20:35:35 +03:00
|
|
|
package frostfs
|
2020-09-08 11:38:49 +03:00
|
|
|
|
|
|
|
import (
|
2021-05-18 11:12:51 +03:00
|
|
|
"fmt"
|
|
|
|
|
2024-12-06 13:59:15 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/frostfs"
|
2023-03-07 16:38:26 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
2022-07-28 19:22:32 +03:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
2021-11-10 14:05:51 +03:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-09-08 11:38:49 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2023-04-26 16:25:50 +03:00
|
|
|
KeyValue []byte
|
|
|
|
ValueValue []byte
|
|
|
|
IDValue []byte
|
2021-11-10 14:05:51 +03:00
|
|
|
|
2023-04-26 16:25:50 +03:00
|
|
|
// TxHashValue is used in notary environmental
|
2021-11-10 14:05:51 +03:00
|
|
|
// for calculating unique but same for
|
|
|
|
// all notification receivers values.
|
2023-04-26 16:25:50 +03:00
|
|
|
TxHashValue util.Uint256
|
2021-11-10 14:05:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// TxHash returns hash of the TX with new epoch
|
|
|
|
// notification.
|
|
|
|
func (u Config) TxHash() util.Uint256 {
|
2023-04-26 16:25:50 +03:00
|
|
|
return u.TxHashValue
|
2020-09-08 11:38:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// MorphEvent implements Neo:Morph Event interface.
|
|
|
|
func (Config) MorphEvent() {}
|
|
|
|
|
2023-04-26 16:25:50 +03:00
|
|
|
func (u Config) ID() []byte { return u.IDValue }
|
2020-11-05 16:26:28 +03:00
|
|
|
|
2023-04-26 16:25:50 +03:00
|
|
|
func (u Config) Key() []byte { return u.KeyValue }
|
2020-09-08 11:38:49 +03:00
|
|
|
|
2023-04-26 16:25:50 +03:00
|
|
|
func (u Config) Value() []byte { return u.ValueValue }
|
2020-09-08 11:38:49 +03:00
|
|
|
|
2022-07-28 19:22:32 +03:00
|
|
|
func ParseConfig(e *state.ContainedNotificationEvent) (event.Event, error) {
|
2024-12-06 13:59:15 +03:00
|
|
|
var sce frostfs.SetConfigEvent
|
|
|
|
if err := sce.FromStackItem(e.Item); err != nil {
|
|
|
|
return nil, fmt.Errorf("parse frostfs.SetConfigEvent: %w", err)
|
2020-09-08 11:38:49 +03:00
|
|
|
}
|
|
|
|
|
2024-12-06 13:59:15 +03:00
|
|
|
return Config{
|
|
|
|
KeyValue: sce.Key,
|
|
|
|
ValueValue: sce.Value,
|
|
|
|
IDValue: sce.Id,
|
|
|
|
TxHashValue: e.Container,
|
|
|
|
}, nil
|
2020-09-08 11:38:49 +03:00
|
|
|
}
|