forked from nspcc-dev/neofs-node
-
Notifications
You must be signed in to change notification settings - Fork 6
/
validator.go
37 lines (32 loc) · 1.05 KB
/
validator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package nodevalidation
import (
"github.com/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap"
apinetmap "github.com/TrueCloudLab/frostfs-sdk-go/netmap"
)
// 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
}