[#227] netmap: Fix minor blots in documentation/code

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-06-14 17:27:51 +03:00 committed by LeL
parent ca523f1ff1
commit d648b86776
10 changed files with 46 additions and 45 deletions

View file

@ -21,19 +21,19 @@ On client side:
import "github.com/nspcc-dev/neofs-api-go/v2/netmap"
var msg netmap.NodeInfo
msg.WriteToV2(&msg)
info.WriteToV2(&msg)
// send msg
On server side:
// recv msg
var info netmap.NodeInfo
var info NodeInfo
err := info.ReadFromV2(msg)
// ...
// process dec
// process info
Using package types in an application is recommended to potentially work with
different protocol versions with which these types are compatible.

View file

@ -20,7 +20,7 @@ func newFilter(name string, k, v string, op netmap.Operation, fs ...Filter) (f F
func newSelector(name string, attr string, count uint32, filter string, clause func(*Selector)) (s Selector) {
s.SetName(name)
s.SelectByBucketAttribute(attr)
s.SetNodeAmount(count)
s.SetNumberOfNodes(count)
clause(&s)
s.SetFilterName(filter)
return s
@ -35,7 +35,7 @@ func newPlacementPolicy(bf uint32, rs []ReplicaDescriptor, ss []Selector, fs []F
}
func newReplica(c uint32, s string) (r ReplicaDescriptor) {
r.SetAmount(c)
r.SetNumberOfObjects(c)
r.SetSelectorName(s)
return r
}

View file

@ -42,6 +42,7 @@ func (n nodes) Hash() uint64 {
if len(n) > 0 {
return n[0].Hash()
}
return 0
}

View file

@ -31,7 +31,7 @@ func (x *NetworkInfo) readFromV2(m netmap.NetworkInfo, checkFieldPresence bool)
}
if checkFieldPresence && c.NumberOfParameters() <= 0 {
return fmt.Errorf("missing network parameters")
return errors.New("missing network parameters")
}
var err error
@ -68,7 +68,7 @@ func (x *NetworkInfo) readFromV2(m netmap.NetworkInfo, checkFieldPresence bool)
configStoragePrice,
configContainerFee,
configNamedContainerFee,
configEigenTrustIterationsAmount,
configEigenTrustNumberOfIterations,
configEpochDuration,
configIRCandidateFee,
configMaxObjSize,
@ -239,7 +239,7 @@ func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []by
configStoragePrice,
configContainerFee,
configNamedContainerFee,
configEigenTrustIterationsAmount,
configEigenTrustNumberOfIterations,
configEpochDuration,
configIRCandidateFee,
configMaxObjSize,
@ -374,29 +374,29 @@ func (x NetworkInfo) EigenTrustAlpha() float64 {
return alpha
}
const configEigenTrustIterationsAmount = "EigenTrustIterations"
const configEigenTrustNumberOfIterations = "EigenTrustIterations"
// SetEigenTrustIterationAmount sets number of iterations of the EigenTrust
// SetNumberOfEigenTrustIterations sets number of iterations of the EigenTrust
// algorithm to perform. The algorithm is used by the storage nodes for
// calculating the reputation values.
//
// See also EigenTrustIterationAmount.
func (x *NetworkInfo) SetEigenTrustIterationAmount(amount uint64) {
x.setConfigUint64(configEigenTrustIterationsAmount, amount)
// See also NumberOfEigenTrustIterations.
func (x *NetworkInfo) SetNumberOfEigenTrustIterations(num uint64) {
x.setConfigUint64(configEigenTrustNumberOfIterations, num)
}
// EigenTrustIterationAmount returns EigenTrust iteration amount set using
// SetEigenTrustIterationAmount.
// NumberOfEigenTrustIterations returns number of EigenTrust iterations set
// using SetNumberOfEigenTrustIterations.
//
// Zero NetworkInfo has zero iteration number.
func (x NetworkInfo) EigenTrustIterationAmount() uint64 {
return x.configUint64(configEigenTrustIterationsAmount)
func (x NetworkInfo) NumberOfEigenTrustIterations() uint64 {
return x.configUint64(configEigenTrustNumberOfIterations)
}
const configEpochDuration = "EpochDuration"
// SetEpochDuration sets NeoFS epoch duration measured in block amount of the
// NeoFS Sidechain.
// SetEpochDuration sets NeoFS epoch duration measured in number of blocks of
// the NeoFS Sidechain.
//
// See also EpochDuration.
func (x *NetworkInfo) SetEpochDuration(blocks uint64) {

View file

@ -161,10 +161,10 @@ func TestNetworkInfo_EigenTrustAlpha(t *testing.T) {
)
}
func TestNetworkInfo_EigenTrustIterationAmount(t *testing.T) {
func TestNetworkInfo_NumberOfEigenTrustIterations(t *testing.T) {
testConfigValue(t,
func(x NetworkInfo) interface{} { return x.EigenTrustIterationAmount() },
func(info *NetworkInfo, val interface{}) { info.SetEigenTrustIterationAmount(val.(uint64)) },
func(x NetworkInfo) interface{} { return x.NumberOfEigenTrustIterations() },
func(info *NetworkInfo, val interface{}) { info.SetNumberOfEigenTrustIterations(val.(uint64)) },
uint64(1), uint64(2),
"EigenTrustIterations", func(val interface{}) []byte {
data := make([]byte, 8)

View file

@ -79,7 +79,7 @@ func (x *NodeInfo) readFromV2(m netmap.NodeInfo, checkFieldPresence bool) error
}
default:
if attributes[i].GetValue() == "" {
return fmt.Errorf("empty value of the attribute #%d", i)
return fmt.Errorf("empty value of the attribute %s", key)
}
}
}

View file

@ -107,15 +107,15 @@ type ReplicaDescriptor struct {
m netmap.Replica
}
// SetAmount sets number of object replicas.
func (r *ReplicaDescriptor) SetAmount(c uint32) {
// SetNumberOfObjects sets number of object replicas.
func (r *ReplicaDescriptor) SetNumberOfObjects(c uint32) {
r.m.SetCount(c)
}
// Amount returns number set using SetAmount.
// NumberOfObjects returns number set using SetNumberOfObjects.
//
// Zero ReplicaDescriptor has zero object amount.
func (r ReplicaDescriptor) Amount() uint32 {
// Zero ReplicaDescriptor has zero number of objects.
func (r ReplicaDescriptor) NumberOfObjects() uint32 {
return r.m.GetCount()
}
@ -142,18 +142,18 @@ func (p *PlacementPolicy) AddReplicas(rs ...ReplicaDescriptor) {
}
}
// NumberOfReplicas returns amount of replica descriptors set using AddReplicas.
// NumberOfReplicas returns number of replica descriptors set using AddReplicas.
//
// Zero PlacementPolicy has no replicas.
func (p PlacementPolicy) NumberOfReplicas() int {
return len(p.replicas)
}
// ReplicaAmountByIndex returns amount of object replicas from the i-th replica
// ReplicaNumberByIndex returns number of object replicas from the i-th replica
// descriptor. Index MUST be in range [0; NumberOfReplicas()).
//
// Zero PlacementPolicy has no replicas.
func (p PlacementPolicy) ReplicaAmountByIndex(i int) uint32 {
func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32 {
return p.replicas[i].GetCount()
}
@ -178,11 +178,11 @@ func (s *Selector) SetName(name string) {
s.m.SetName(name)
}
// SetNodeAmount sets number of nodes to select from the bucket.
// SetNumberOfNodes sets number of nodes to select from the bucket.
//
// Zero Selector selects nothing.
func (s *Selector) SetNodeAmount(amount uint32) {
s.m.SetCount(amount)
func (s *Selector) SetNumberOfNodes(num uint32) {
s.m.SetCount(num)
}
// SelectByBucketAttribute sets attribute of the bucket to select nodes from.
@ -239,7 +239,7 @@ type Filter struct {
}
// SetName sets name with which the Filter can be referenced or, for inner filters,
// to which the Filter references. Top-level filters MUST have be named. The name
// to which the Filter references. Top-level filters MUST be named. The name
// MUST NOT be '*'.
//
// Zero Filter is unnamed.

View file

@ -35,7 +35,7 @@ func (c *context) processSelectors(p PlacementPolicy) error {
return nil
}
// calcNodesCount returns amount of buckets and minimum number of nodes in every bucket
// calcNodesCount returns number of buckets and minimum number of nodes in every bucket
// for the given selector.
func calcNodesCount(s netmap.Selector) (int, int) {
switch s.GetClause() {

View file

@ -254,15 +254,15 @@ func TestSelector_SetName(t *testing.T) {
require.Equal(t, name, s.m.GetName())
}
func TestSelector_SetNodeAmount(t *testing.T) {
const amount = 3
func TestSelector_SetNumberOfNodes(t *testing.T) {
const num = 3
var s Selector
require.Zero(t, s.m.GetCount())
s.SetNodeAmount(amount)
s.SetNumberOfNodes(num)
require.EqualValues(t, amount, s.m.GetCount())
require.EqualValues(t, num, s.m.GetCount())
}
func TestSelectorClauses(t *testing.T) {

View file

@ -23,7 +23,7 @@ func Filter() netmap.Filter {
// Replica returns random netmap.ReplicaDescriptor.
func Replica() (x netmap.ReplicaDescriptor) {
x.SetAmount(666)
x.SetNumberOfObjects(666)
x.SetSelectorName("selector")
return
@ -31,7 +31,7 @@ func Replica() (x netmap.ReplicaDescriptor) {
// Selector returns random netmap.Selector.
func Selector() (x netmap.Selector) {
x.SetNodeAmount(11)
x.SetNumberOfNodes(11)
x.SetName("name")
x.SetFilterName("filter")
x.SelectByBucketAttribute("attribute")
@ -60,7 +60,7 @@ func NetworkInfo() (x netmap.NetworkInfo) {
x.SetStoragePrice(2)
x.SetContainerFee(3)
x.SetEigenTrustAlpha(0.4)
x.SetEigenTrustIterationAmount(5)
x.SetNumberOfEigenTrustIterations(5)
x.SetEpochDuration(6)
x.SetIRCandidateFee(7)
x.SetMaxObjectSize(8)