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
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
sed "s/-/~/")-${OS_RELEASE}

.PHONY: help all images dep clean fmts fmt imports test lint docker/lint
.PHONY: help all images dep clean fmts fmt modernize imports test lint docker/lint
prepare-release debpackage

# To build a specific binary, use it's name prefix with bin/ as a target
Expand Down Expand Up @@ -111,7 +111,7 @@ docker/%:


# Run all code formatters
fmts: fmt imports
fmts: fmt imports modernize

# Reformat code
fmt:
Expand All @@ -123,6 +123,11 @@ imports:
@echo "⇒ Processing goimports check"
@goimports -w $$(find . -type f -name '*.go' -not -path '*.pb.go')

# Prettify code
modernize:
@echo "⇒ Processing modernize check"
@go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./...

# Run Unit Test with go test
test:
@echo "⇒ Running go test"
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/fschain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func probeContractName(ctrPath string) (string, error) {

var ctrName string
for i := range ds {
if strings.HasSuffix(ds[i].Name(), "_contract.nef") {
ctrName = strings.TrimSuffix(ds[i].Name(), "_contract.nef")
if before, ok := strings.CutSuffix(ds[i].Name(), "_contract.nef"); ok {
ctrName = before
break
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/storagecfg/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ func (filenameCompleter) Do(line []rune, pos int) (newLine [][]rune, length int)

for i := range de {
name := filepath.Join(dir, de[i].Name())
if strings.HasPrefix(name, prefix) {
tail := []rune(strings.TrimPrefix(name, prefix))
if after, ok := strings.CutPrefix(name, prefix); ok {
tail := []rune(after)
if de[i].IsDir() {
tail = append(tail, filepath.Separator)
}
Expand Down
7 changes: 2 additions & 5 deletions cmd/neofs-node/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ func newNetmapWithContainer(tb testing.TB, nodeNum int, selected ...[]int) ([]ne
nodes[i].SetPublicKey(key)

for j := range selected {
for k := range selected[j] {
if i == selected[j][k] {
nodes[i].SetAttribute("attr"+strconv.Itoa(j), "true")
break
}
if slices.Contains(selected[j], i) {
nodes[i].SetAttribute("attr"+strconv.Itoa(j), "true")
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/innerring/internal/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"maps"
"math"
"time"

Expand Down Expand Up @@ -169,10 +170,7 @@ func New(cfg *config.Consensus, wallet *config.Wallet, errChan chan<- error, log
cfgBaseProto.Genesis.MaxValidUntilBlockIncrement = cfg.MaxValidUntilBlockIncrement
cfgBaseProto.Hardforks = cfg.Hardforks.Name
if cfg.ValidatorsHistory.Height != nil {
cfgBaseProto.ValidatorsHistory = make(map[uint32]uint32, len(cfg.ValidatorsHistory.Height))
for height, num := range cfg.ValidatorsHistory.Height {
cfgBaseProto.ValidatorsHistory[height] = num
}
cfgBaseProto.ValidatorsHistory = maps.Clone(cfg.ValidatorsHistory.Height)
} else {
cfgBaseProto.ValidatorsCount = uint32(len(standByCommittee))
}
Expand Down
15 changes: 3 additions & 12 deletions pkg/local_object_storage/metabase/put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,7 @@ func BenchmarkPutBatch(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i += 10 {
end := i + 10
if end > b.N {
end = b.N
}
end := min(i+10, b.N)
if err := db.PutBatch(objs[i:end]); err != nil {
b.Fatal(err)
}
Expand All @@ -693,10 +690,7 @@ func BenchmarkPutBatch(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i += 100 {
end := i + 100
if end > b.N {
end = b.N
}
end := min(i+100, b.N)
if err := db.PutBatch(objs[i:end]); err != nil {
b.Fatal(err)
}
Expand All @@ -709,10 +703,7 @@ func BenchmarkPutBatch(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i += 1000 {
end := i + 1000
if end > b.N {
end = b.N
}
end := min(i+1000, b.N)
if err := db.PutBatch(objs[i:end]); err != nil {
b.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/morph/client/netmap/add_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package netmap

import (
"fmt"
"maps"
"slices"

"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
Expand All @@ -19,9 +20,7 @@ func (c *Client) AddPeer(ni netmap.NodeInfo, pkey *keys.PublicKey) error {
State: netmaprpc.NodeStateOnline,
}
node.Addresses = slices.Collect(ni.NetworkEndpoints())
for k, v := range ni.Attributes() {
node.Attributes[k] = v
}
maps.Insert(node.Attributes, ni.Attributes())

prm := client.InvokePrm{}
prm.SetMethod(addNodeMethod)
Expand Down
6 changes: 2 additions & 4 deletions pkg/services/meta/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,12 @@ func (m *Meta) handleEpochNotification(e uint64) error {
defer m.stM.RUnlock()
var gcWG sync.WaitGroup
for cID, st := range m.storages {
gcWG.Add(1)
go func() {
defer gcWG.Done()
gcWG.Go(func() {
err := st.handleNewEpoch(e)
if err != nil {
l.Error("handling new epoch", zap.Stringer("cID", cID), zap.Error(err))
}
}()
})
}
gcWG.Wait()

Expand Down
5 changes: 1 addition & 4 deletions pkg/services/object/get/assemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ func (exec *execCtx) initFromChild(obj oid.ID) (*oid.ID, []oid.ID) {

to := uint64(0)
if seekOff+seekLen > startRight+from {
to = seekOff + seekLen - startRight
if to > childSize {
to = childSize
}
to = min(seekOff+seekLen-startRight, childSize)
}

segLen := uint64(0)
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/object/put/distibuted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func allocNodes(n []uint) [][]netmap.NodeInfo {
for i := range res {
res[i] = make([]netmap.NodeInfo, n[i])
for j := range res[i] {
res[i][j].SetPublicKey([]byte(fmt.Sprintf("pub_%d_%d", i, j)))
res[i][j].SetPublicKey(fmt.Appendf(nil, "pub_%d_%d", i, j))
res[i][j].SetNetworkEndpoints(
"localhost:"+strconv.Itoa(1e4+i*100+2*j),
"localhost:"+strconv.Itoa(1e4+i*100+2*j+1),
Expand Down
Loading