Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/internal/cmderr/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func ExitOnErr(err error) {
if !errors.As(err, &e) {
e.Code = 1
}
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, "Error:", err)
os.Exit(e.Code)
}
}
8 changes: 4 additions & 4 deletions cmd/neofs-adm/internal/modules/fschain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
nbuf := make([]byte, 8)
copy(nbuf, v)
n := binary.LittleEndian.Uint64(nbuf)
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%d (int)\n", k, n)))
_, _ = fmt.Fprintf(tw, "%s:\t%d (int)\n", k, n)
case netmapEigenTrustAlphaKey:
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (str)\n", k, v)))
_, _ = fmt.Fprintf(tw, "%s:\t%s (str)\n", k, v)
case netmapHomomorphicHashDisabledKey:
vBool, err := tuple[1].TryBool()
if err != nil {
return invalidConfigValueErr(k)
}

_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%t (bool)\n", k, vBool)))
_, _ = fmt.Fprintf(tw, "%s:\t%t (bool)\n", k, vBool)
default:
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (hex)\n", k, hex.EncodeToString(v))))
_, _ = fmt.Fprintf(tw, "%s:\t%s (hex)\n", k, hex.EncodeToString(v))
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-adm/internal/modules/fschain/dump_hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ func printContractInfo(cmd *cobra.Command, infos []contractDumpInfo) {
if info.version == "" {
info.version = "unknown"
}
_, _ = tw.Write([]byte(fmt.Sprintf("%s\t(%s):\t%s\t%s\n",
_, _ = fmt.Fprintf(tw, "%s\t(%s):\t%s\t%s\n",
info.name, info.version, info.hash.StringLE(),
timeStr)))
timeStr)
}
_ = tw.Flush()

Expand All @@ -221,7 +221,7 @@ func fillContractVersion(cmd *cobra.Command, c Client, infos []contractDumpInfo)

script := sub.Bytes()
emit.Instruction(bw.BinWriter, opcode.TRY, []byte{byte(3 + len(script) + 2), 0})
bw.BinWriter.WriteBytes(script)
bw.WriteBytes(script)
emit.Instruction(bw.BinWriter, opcode.ENDTRY, []byte{2 + 1})
emit.Opcodes(bw.BinWriter, opcode.PUSH0)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/fschain/dump_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func dumpNames(cmd *cobra.Command, _ []string) error {
buf := bytes.NewBuffer(nil)
tw := tabwriter.NewWriter(buf, 0, 2, 2, ' ', 0)
for i := range res {
_, _ = tw.Write([]byte(fmt.Sprintf("%s\t%s\n",
res[i].name, time.UnixMilli(res[i].exp).String())))
_, _ = fmt.Fprintf(tw, "%s\t%s\n",
res[i].name, time.UnixMilli(res[i].exp).String())
}
_ = tw.Flush()

Expand Down
6 changes: 1 addition & 5 deletions cmd/neofs-adm/main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package main

import (
"fmt"

"github.com/nspcc-dev/neofs-node/cmd/internal/cmderr"
"github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules"
)

func main() {
err := modules.Execute()
if err != nil {
cmderr.ExitOnErr(fmt.Errorf("Error: %w\n", err))
}
cmderr.ExitOnErr(err)
}
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/acl/extended/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ func createEACL(cmd *cobra.Command, _ []string) error {
var containerID cid.ID
if cidArg != "" {
if err := containerID.DecodeString(cidArg); err != nil {
return fmt.Errorf("invalid container ID: %w\n", err)
return fmt.Errorf("invalid container ID: %w", err)
}
}

rulesFile, err := getRulesFromFile(fileArg)
if err != nil {
return fmt.Errorf("can't read rules from file: %w\n", err)
return fmt.Errorf("can't read rules from file: %w", err)
}

rules = append(rules, rulesFile...)
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-cli/modules/container/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ Only owner of the container has a permission to remove container.`,
}

if len(res) != 0 {
return fmt.Errorf("Container wasn't removed because LOCK objects were found.\n"+
"Use --%s flag to remove anyway.", commonflags.ForceFlag)
return fmt.Errorf("container wasn't removed because LOCK objects were found.\n"+
"Use --%s flag to remove anyway", commonflags.ForceFlag)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-cli/modules/object/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var objectLockCmd = &cobra.Command{
var cnr cid.ID
err := cnr.DecodeString(cidRaw)
if err != nil {
return fmt.Errorf("Incorrect container arg: %w", err)
return fmt.Errorf("incorrect container arg: %w", err)
}

oidsRaw, _ := cmd.Flags().GetStringSlice(commonflags.OIDFlag)
Expand Down Expand Up @@ -59,7 +59,7 @@ var objectLockCmd = &cobra.Command{

currEpoch, err := internalclient.GetCurrentEpoch(ctx, endpoint)
if err != nil {
return fmt.Errorf("Request current epoch: %w", err)
return fmt.Errorf("request current epoch: %w", err)
}

exp = currEpoch + lifetime
Expand Down Expand Up @@ -107,7 +107,7 @@ var objectLockCmd = &cobra.Command{
err = fmt.Errorf("finish object stream: %w", err)
}
if err != nil {
return fmt.Errorf("Store lock object for %s in NeoFS: %w", locked, err)
return fmt.Errorf("store lock object for %s in NeoFS: %w", locked, err)
}

cmd.Printf("Lock object ID for %s locked object: %s\n", locked, wrt.GetResult().StoredObjectID())
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-lens/internal/storage/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func listFunc(cmd *cobra.Command, _ []string) error {
return nil
}
if err != nil {
return fmt.Errorf("Storage iterator failure: %w", err)
return fmt.Errorf("storage iterator failure: %w", err)
}
}
for _, at := range addrs {
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func initAccountingService(c *cfg) {
initMorphComponents(c)
}

balanceMorphWrapper, err := balance.NewFromMorph(c.cfgMorph.client, c.shared.basics.balanceSH)
balanceMorphWrapper, err := balance.NewFromMorph(c.cfgMorph.client, c.balanceSH)
fatalOnErr(err)

server := accountingService.New(&c.key.PrivateKey, c.networkState, balanceMorphWrapper)
Expand Down
20 changes: 10 additions & 10 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ func initCfg(appCfg *config.Config) *cfg {
wg: new(sync.WaitGroup),
apiVersion: version.Current(),
}
c.internals.healthStatus.Store(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED))
c.healthStatus.Store(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED))

c.internals.logLevel, err = zap.ParseAtomicLevel(c.appCfg.Logger.Level)
c.logLevel, err = zap.ParseAtomicLevel(c.appCfg.Logger.Level)
fatalOnErr(err)

logCfg := zap.NewProductionConfig()
logCfg.Level = c.internals.logLevel
logCfg.Level = c.logLevel
logCfg.Encoding = c.appCfg.Logger.Encoding
if !c.appCfg.Logger.Sampling.Enabled {
logCfg.Sampling = nil
Expand All @@ -367,7 +367,7 @@ func initCfg(appCfg *config.Config) *cfg {
logCfg.EncoderConfig.EncodeTime = func(_ time.Time, _ zapcore.PrimitiveArrayEncoder) {}
}

c.internals.log, err = logCfg.Build(
c.log, err = logCfg.Build(
zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)),
)
fatalOnErr(err)
Expand Down Expand Up @@ -399,7 +399,7 @@ func initCfg(appCfg *config.Config) *cfg {
workerPool: containerWorkerPool,
}
c.cfgNetmap = cfgNetmap{
state: c.basics.networkState,
state: c.networkState,
workerPool: netmapWorkerPool,
needBootstrap: !relayOnly,
}
Expand All @@ -420,7 +420,7 @@ func initCfg(appCfg *config.Config) *cfg {
c.ownerIDFromKey = user.NewFromECDSAPublicKey(key.PrivateKey.PublicKey)

c.metricsCollector = metrics.NewNodeMetrics(misc.Version)
c.basics.networkState.metrics = c.metricsCollector
c.networkState.metrics = c.metricsCollector

c.veryLastClosers = make(map[string]func())

Expand Down Expand Up @@ -464,7 +464,7 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor
}

cli, err := client.New(key,
client.WithContext(c.internals.ctx),
client.WithContext(c.ctx),
client.WithDialTimeout(c.appCfg.FSChain.DialTimeout),
client.WithLogger(c.log),
client.WithAutoFSChainScope(),
Expand Down Expand Up @@ -664,15 +664,15 @@ func (c *cfg) configWatcher(ctx context.Context) {

// Logger

err = c.internals.logLevel.UnmarshalText([]byte(c.appCfg.Logger.Level))
err = c.logLevel.UnmarshalText([]byte(c.appCfg.Logger.Level))
if err != nil {
c.log.Error("invalid logger level configuration", zap.Error(err))
continue
}

// Policer

c.shared.policer.Reload(c.policerOpts()...)
c.policer.Reload(c.policerOpts()...)

// Storage Engine

Expand Down Expand Up @@ -704,7 +704,7 @@ func (c *cfg) configWatcher(ctx context.Context) {

var p meta.Parameters
p.NeoEnpoints = c.appCfg.FSChain.Endpoints
err = c.shared.metaService.Reload(p)
err = c.metaService.Reload(p)
if err != nil {
c.log.Error("failed to reload meta service configuration", zap.Error(err))
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-node/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func initControlService(c *cfg) {
rawPubs = append(rawPubs, pubs[i].Bytes())
}

c.shared.control = controlSvc.New(&c.key.PrivateKey, rawPubs, c)
c.control = controlSvc.New(&c.key.PrivateKey, rawPubs, c)

lis, err := net.Listen("tcp", endpoint)
if err != nil {
Expand All @@ -38,7 +38,7 @@ func initControlService(c *cfg) {
stopGRPC("NeoFS Control API", c.cfgControlService.server, c.log)
})

control.RegisterControlServiceServer(c.cfgControlService.server, c.shared.control)
control.RegisterControlServiceServer(c.cfgControlService.server, c.control)
c.wg.Add(1)
go func() {
runAndLog(c, "control", false, func(c *cfg) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func initApp(c *cfg) {

c.workers = append(c.workers, newWorkerFromFunc(c.configWatcher))

c.shared.control.MarkReady(
c.control.MarkReady(
c.cfgObject.cfgLocalStorage.localStorage,
c.netMapSource,
c.cnrSrc,
Expand Down Expand Up @@ -208,7 +208,7 @@ func (c *cfg) onShutdown(f func()) {
func (c *cfg) restartMorph() error {
c.log.Info("restarting internal services because of RPC connection loss...")

c.shared.resetCaches()
c.resetCaches()

epoch, ni, err := getNetworkState(c)
if err != nil {
Expand All @@ -218,7 +218,7 @@ func (c *cfg) restartMorph() error {
updateLocalState(c, epoch, ni)

// drop expired sessions if any has appeared while node was sleeping
c.shared.privateTokenStore.RemoveOld(epoch)
c.privateTokenStore.RemoveOld(epoch)

// bootstrap node after every reconnection cause the longevity of
// a connection downstate is unpredictable and bootstrap TX is a
Expand Down
12 changes: 6 additions & 6 deletions cmd/neofs-node/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func initMeta(c *cfg) {

c.cfgMeta.network = &neofsNetwork{
key: c.binPublicKey,
cnrClient: c.basics.cCli,
cnrClient: c.cCli,
containers: c.cnrSrc,
network: c.basics.netMapSource,
network: c.netMapSource,
header: c.cfgObject.getSvc,
}

Expand All @@ -40,18 +40,18 @@ func initMeta(c *cfg) {
Network: c.cfgMeta.network,
Timeout: c.appCfg.FSChain.DialTimeout,
NeoEnpoints: c.appCfg.FSChain.Endpoints,
ContainerHash: c.basics.containerSH,
NetmapHash: c.basics.netmapSH,
ContainerHash: c.containerSH,
NetmapHash: c.netmapSH,
RootPath: c.appCfg.Meta.Path,
}
if p.RootPath == "" {
p.RootPath = "metadata"
}
c.shared.metaService, err = meta.New(p)
c.metaService, err = meta.New(p)
fatalOnErr(err)

c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
err = c.shared.metaService.Run(ctx)
err = c.metaService.Run(ctx)
if err != nil {
c.internalErr <- fmt.Errorf("meta data service error: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-node/morph.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
func initMorphComponents(c *cfg) {
var err error

morphCli := c.shared.basics.cli
morphCli := c.cli
c.cfgMorph.client = morphCli

c.onShutdown(morphCli.Close)
Expand Down Expand Up @@ -82,8 +82,8 @@ func listenMorphNotifications(c *cfg) {

return res, err
})
registerNotificationHandlers(c.shared.basics.netmapSH, lis, c.cfgNetmap.parsers, c.cfgNetmap.subscribers)
registerNotificationHandlers(c.shared.basics.containerSH, lis, c.cfgContainer.parsers, c.cfgContainer.subscribers)
registerNotificationHandlers(c.netmapSH, lis, c.cfgNetmap.parsers, c.cfgNetmap.subscribers)
registerNotificationHandlers(c.containerSH, lis, c.cfgContainer.parsers, c.cfgContainer.subscribers)

lis.RegisterHeaderHandler(func(block *block.Header) {
c.log.Debug("new block", zap.Uint32("index", block.Index))
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/netmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func initNetmapService(c *cfg) {
l := c.log.With(zap.Uint64("epoch", epoch))
l.Info("new epoch event, requesting new network map to sync SN connection caches...")

nm, err := c.shared.netMapSource.GetNetMapByEpoch(epoch)
nm, err := c.netMapSource.GetNetMapByEpoch(epoch)
if err != nil {
l.Info("failed to get network map by new epoch from event to sync SN connection cache", zap.Error(err))
return
Expand Down
Loading
Loading