Evgenii Stratonikov
1c12f23b84
All checks were successful
Tests and linters / Run gofumpt (push) Successful in 1m10s
Vulncheck / Vulncheck (push) Successful in 2m55s
Tests and linters / Staticcheck (push) Successful in 3m2s
Build / Build Components (push) Successful in 3m42s
Pre-commit hooks / Pre-commit (push) Successful in 3m46s
Tests and linters / Lint (push) Successful in 4m19s
Tests and linters / Tests (push) Successful in 4m23s
Tests and linters / gopls check (push) Successful in 4m44s
Tests and linters / Tests with -race (push) Successful in 5m18s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package netmap
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/netmap"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
)
|
|
|
|
// NewEpoch is a new epoch Neo:Morph event.
|
|
type NewEpoch struct {
|
|
Num uint64
|
|
|
|
// Hash is used in notary environmental
|
|
// for calculating unique but same for
|
|
// all notification receivers values.
|
|
Hash util.Uint256
|
|
}
|
|
|
|
// MorphEvent implements Neo:Morph Event interface.
|
|
func (NewEpoch) MorphEvent() {}
|
|
|
|
// EpochNumber returns new epoch number.
|
|
func (s NewEpoch) EpochNumber() uint64 {
|
|
return s.Num
|
|
}
|
|
|
|
// TxHash returns hash of the TX with new epoch
|
|
// notification.
|
|
func (s NewEpoch) TxHash() util.Uint256 {
|
|
return s.Hash
|
|
}
|
|
|
|
// ParseNewEpoch is a parser of new epoch notification event.
|
|
//
|
|
// Result is type of NewEpoch.
|
|
func ParseNewEpoch(e *state.ContainedNotificationEvent) (event.Event, error) {
|
|
var nee netmap.NewEpochEvent
|
|
if err := nee.FromStackItem(e.Item); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return NewEpoch{
|
|
Num: uint64(nee.Epoch.Uint64()),
|
|
Hash: e.Container,
|
|
}, nil
|
|
}
|