forked from TrueCloudLab/frostfs-node
[#249] node: Drop subnet from IR and morph
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
d757d881d0
commit
f07d4158f5
41 changed files with 55 additions and 1935 deletions
|
@ -1,42 +0,0 @@
|
|||
package subnet
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
morphsubnet "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/subnet"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||
subnetid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/subnet/id"
|
||||
)
|
||||
|
||||
// VerifyAndUpdate calls subnet contract's `NodeAllowed` method.
|
||||
// Removes subnets that have not been approved by the contract.
|
||||
func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
|
||||
prm := morphsubnet.NodeAllowedPrm{}
|
||||
|
||||
err := n.IterateSubnets(func(id subnetid.ID) error {
|
||||
// every node can be bootstrapped
|
||||
// to the zero subnetwork
|
||||
if subnetid.IsZero(id) {
|
||||
return nil
|
||||
}
|
||||
|
||||
prm.SetID(id.Marshal())
|
||||
prm.SetNode(n.PublicKey())
|
||||
|
||||
res, err := v.subnetClient.NodeAllowed(prm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not call `NodeAllowed` contract method: %w", err)
|
||||
}
|
||||
|
||||
if !res.Allowed() {
|
||||
return netmap.ErrRemoveSubnet
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not verify subnet entrance of the node: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package subnet
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
morphsubnet "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/subnet"
|
||||
)
|
||||
|
||||
// Validator is an utility that verifies node subnet
|
||||
// allowance.
|
||||
//
|
||||
// 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 {
|
||||
subnetClient *morphsubnet.Client
|
||||
}
|
||||
|
||||
// Prm groups the required parameters of the Validator's constructor.
|
||||
//
|
||||
// All values must comply with the requirements imposed on them.
|
||||
// Passing incorrect parameter values will result in constructor
|
||||
// failure (error or panic depending on the implementation).
|
||||
type Prm struct {
|
||||
SubnetClient *morphsubnet.Client
|
||||
}
|
||||
|
||||
// New creates a new instance of the Validator.
|
||||
//
|
||||
// The created Validator does not require additional
|
||||
// initialization and is completely ready for work.
|
||||
func New(prm Prm) (*Validator, error) {
|
||||
switch {
|
||||
case prm.SubnetClient == nil:
|
||||
return nil, errors.New("ir/nodeValidator: subnet client is not set")
|
||||
}
|
||||
|
||||
return &Validator{
|
||||
subnetClient: prm.SubnetClient,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue