[#622] pkg/innerring: Add multiaddress validator

Add multiaddress validator that calls
`network.VerifyAddress`.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-18 13:18:48 +03:00 committed by Pavel Karpy
parent ea5c74e761
commit 53b7e05b65
2 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,18 @@
package maddress
import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
"github.com/nspcc-dev/neofs-node/pkg/network"
)
// VerifyAndUpdate calls network.VerifyAddress.
func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
err := network.VerifyMultiAddress(n)
if err != nil {
return fmt.Errorf("could not verify multiaddress: %w", err)
}
return nil
}

View file

@ -0,0 +1,17 @@
package maddress
// Validator is an utility that verifies node
// multiaddress.
//
// For correct operation, Validator must be created
// using the constructor (New). After successful creation,
// the Validator is immediately ready to work through API.
type Validator struct {}
// New creates a new instance of the Validator.
//
// The created Validator does not require additional
// initialization and is completely ready for work.
func New() *Validator {
return &Validator{}
}