Alexander Chuprov
945b7c740b
All checks were successful
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m47s
Tests and linters / Run gofumpt (pull_request) Successful in 3m59s
Tests and linters / gopls check (pull_request) Successful in 4m8s
Build / Build Components (pull_request) Successful in 4m31s
Vulncheck / Vulncheck (pull_request) Successful in 4m29s
Tests and linters / Staticcheck (pull_request) Successful in 5m3s
Tests and linters / Lint (pull_request) Successful in 5m23s
Tests and linters / Tests with -race (pull_request) Successful in 7m25s
DCO action / DCO (pull_request) Successful in 1m6s
Tests and linters / Tests (pull_request) Successful in 2m40s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package netmap
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func ForceNewEpochCmd(cmd *cobra.Command, _ []string) error {
|
|
wCtx, err := helper.NewInitializeContext(cmd, viper.GetViper())
|
|
if err != nil {
|
|
return fmt.Errorf("can't initialize context: %w", err)
|
|
}
|
|
|
|
r := management.NewReader(wCtx.ReadOnlyInvoker)
|
|
cs, err := helper.GetContractByID(r, 1)
|
|
if err != nil {
|
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
|
}
|
|
|
|
nmHash, err := helper.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, helper.DomainOf(constants.NetmapContract))
|
|
if err != nil {
|
|
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
|
}
|
|
|
|
bw := io.NewBufBinWriter()
|
|
if err := helper.EmitNewEpochCall(bw, wCtx, nmHash, viper.GetInt64(commonflags.DeltaFlag)); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err = wCtx.SendConsensusTx(bw.Bytes()); err == nil {
|
|
err = wCtx.AwaitTx()
|
|
}
|
|
if err != nil && strings.Contains(err.Error(), "invalid epoch") {
|
|
cmd.Println("Epoch has already ticked.")
|
|
return nil
|
|
}
|
|
return err
|
|
}
|