Skip to content

Commit

Permalink
ir: Add node info attribute uniqueness validation
Browse files Browse the repository at this point in the history
That is the API restriction. Add this check to the `maddress` validator and
rename in to `structure` validator.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Sep 7, 2023
1 parent de58dd3 commit 757b90e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
nodevalidator "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap/nodevalidation"
availabilityvalidator "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap/nodevalidation/availability"
addrvalidator "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap/nodevalidation/maddress"
statevalidation "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap/nodevalidation/state"
addrvalidator "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap/nodevalidation/structure"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/reputation"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
auditSettlement "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement/audit"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package maddress
package structure

import (
"fmt"
Expand All @@ -14,5 +14,12 @@ func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
return fmt.Errorf("could not verify multiaddress: %w", err)
}

return nil
attrM := make(map[string]struct{}, n.NumberOfAttributes())
n.IterateAttributes(func(key, _ string) {
if _, alreadyHave := attrM[key]; alreadyHave {
err = fmt.Errorf("repeating node attribute: '%s'", key)
}
})

return err
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package maddress
package structure

// Validator is an utility that verifies node
// multiaddress.
// Validator is a utility that verifies announced node
// structure.
//
// For correct operation, the Validator must be created
// using the constructor (New). After successful creation,
Expand Down

0 comments on commit 757b90e

Please sign in to comment.