2020-07-10 14:17:51 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2024-12-05 08:58:38 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/netmap"
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
2022-07-28 16:22:32 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
2021-11-10 11:05:51 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-07-10 14:17:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewEpoch is a new epoch Neo:Morph event.
|
|
|
|
type NewEpoch struct {
|
2023-04-27 14:57:27 +00:00
|
|
|
Num uint64
|
2021-11-10 11:05:51 +00:00
|
|
|
|
2023-04-27 14:57:27 +00:00
|
|
|
// Hash is used in notary environmental
|
2021-11-10 11:05:51 +00:00
|
|
|
// for calculating unique but same for
|
|
|
|
// all notification receivers values.
|
2023-04-27 14:57:27 +00:00
|
|
|
Hash util.Uint256
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MorphEvent implements Neo:Morph Event interface.
|
|
|
|
func (NewEpoch) MorphEvent() {}
|
|
|
|
|
|
|
|
// EpochNumber returns new epoch number.
|
|
|
|
func (s NewEpoch) EpochNumber() uint64 {
|
2023-04-27 14:57:27 +00:00
|
|
|
return s.Num
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|
|
|
|
|
2021-11-10 11:05:51 +00:00
|
|
|
// TxHash returns hash of the TX with new epoch
|
|
|
|
// notification.
|
|
|
|
func (s NewEpoch) TxHash() util.Uint256 {
|
2023-04-27 14:57:27 +00:00
|
|
|
return s.Hash
|
2021-11-10 11:05:51 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 14:17:51 +00:00
|
|
|
// ParseNewEpoch is a parser of new epoch notification event.
|
|
|
|
//
|
|
|
|
// Result is type of NewEpoch.
|
2022-07-28 16:22:32 +00:00
|
|
|
func ParseNewEpoch(e *state.ContainedNotificationEvent) (event.Event, error) {
|
2024-12-05 08:58:38 +00:00
|
|
|
var nee netmap.NewEpochEvent
|
|
|
|
if err := nee.FromStackItem(e.Item); err != nil {
|
|
|
|
return nil, err
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NewEpoch{
|
2024-12-05 08:58:38 +00:00
|
|
|
Num: uint64(nee.Epoch.Uint64()),
|
2023-04-27 14:57:27 +00:00
|
|
|
Hash: e.Container,
|
2020-07-10 14:17:51 +00:00
|
|
|
}, nil
|
|
|
|
}
|