2021-06-18 10:35:31 +00:00
|
|
|
package nodevalidation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
|
2021-11-10 07:08:33 +00:00
|
|
|
apinetmap "github.com/nspcc-dev/neofs-sdk-go/netmap"
|
2021-06-18 10:35:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CompositeValidator wraps `netmap.NodeValidator`s.
|
|
|
|
//
|
|
|
|
// For correct operation, CompositeValidator must be created
|
|
|
|
// using the constructor (New). After successful creation,
|
|
|
|
// the CompositeValidator is immediately ready to work through
|
|
|
|
// API.
|
|
|
|
type CompositeValidator struct {
|
|
|
|
validators []netmap.NodeValidator
|
|
|
|
}
|
|
|
|
|
|
|
|
// New creates a new instance of the CompositeValidator.
|
|
|
|
//
|
|
|
|
// The created CompositeValidator does not require additional
|
|
|
|
// initialization and is completely ready for work.
|
|
|
|
func New(validators ...netmap.NodeValidator) *CompositeValidator {
|
|
|
|
return &CompositeValidator{validators}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VerifyAndUpdate passes apinetmap.NodeInfo to wrapped validators.
|
|
|
|
//
|
|
|
|
// If error appears, returns it immediately.
|
|
|
|
func (c *CompositeValidator) VerifyAndUpdate(ni *apinetmap.NodeInfo) error {
|
|
|
|
for _, v := range c.validators {
|
|
|
|
if err := v.VerifyAndUpdate(ni); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|