[#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" import "github.com/nspcc-dev/neofs-api-go/v2/netmap"
var msg netmap.NodeInfo var msg netmap.NodeInfo
msg.WriteToV2(&msg) info.WriteToV2(&msg)
// send msg // send msg
On server side: On server side:
// recv msg // recv msg
var info netmap.NodeInfo var info NodeInfo
err := info.ReadFromV2(msg) err := info.ReadFromV2(msg)
// ... // ...
// process dec // process info
Using package types in an application is recommended to potentially work with Using package types in an application is recommended to potentially work with
different protocol versions with which these types are compatible. 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) { func newSelector(name string, attr string, count uint32, filter string, clause func(*Selector)) (s Selector) {
s.SetName(name) s.SetName(name)
s.SelectByBucketAttribute(attr) s.SelectByBucketAttribute(attr)
s.SetNodeAmount(count) s.SetNumberOfNodes(count)
clause(&s) clause(&s)
s.SetFilterName(filter) s.SetFilterName(filter)
return s return s
@ -35,7 +35,7 @@ func newPlacementPolicy(bf uint32, rs []ReplicaDescriptor, ss []Selector, fs []F
} }
func newReplica(c uint32, s string) (r ReplicaDescriptor) { func newReplica(c uint32, s string) (r ReplicaDescriptor) {
r.SetAmount(c) r.SetNumberOfObjects(c)
r.SetSelectorName(s) r.SetSelectorName(s)
return r return r
} }

View file

@ -42,6 +42,7 @@ func (n nodes) Hash() uint64 {
if len(n) > 0 { if len(n) > 0 {
return n[0].Hash() return n[0].Hash()
} }
return 0 return 0
} }
@ -73,8 +74,8 @@ func flattenNodes(ns []nodes) nodes {
// PlacementVectors sorts container nodes returned by ContainerNodes method // PlacementVectors sorts container nodes returned by ContainerNodes method
// and returns placement vectors for the entity identified by the given pivot. // and returns placement vectors for the entity identified by the given pivot.
// For example,in order to build node list to store the object, binary-encoded // For example, in order to build node list to store the object, binary-encoded
// object identifier can be used as pivot. Result is deterministic for // object identifier can be used as pivot. Result is deterministic for
// the fixed NetMap and parameters. // the fixed NetMap and parameters.
func (m NetMap) PlacementVectors(vectors [][]NodeInfo, pivot []byte) ([][]NodeInfo, error) { func (m NetMap) PlacementVectors(vectors [][]NodeInfo, pivot []byte) ([][]NodeInfo, error) {
h := hrw.Hash(pivot) h := hrw.Hash(pivot)

View file

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

View file

@ -79,7 +79,7 @@ func (x *NodeInfo) readFromV2(m netmap.NodeInfo, checkFieldPresence bool) error
} }
default: default:
if attributes[i].GetValue() == "" { 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 m netmap.Replica
} }
// SetAmount sets number of object replicas. // SetNumberOfObjects sets number of object replicas.
func (r *ReplicaDescriptor) SetAmount(c uint32) { func (r *ReplicaDescriptor) SetNumberOfObjects(c uint32) {
r.m.SetCount(c) r.m.SetCount(c)
} }
// Amount returns number set using SetAmount. // NumberOfObjects returns number set using SetNumberOfObjects.
// //
// Zero ReplicaDescriptor has zero object amount. // Zero ReplicaDescriptor has zero number of objects.
func (r ReplicaDescriptor) Amount() uint32 { func (r ReplicaDescriptor) NumberOfObjects() uint32 {
return r.m.GetCount() 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. // Zero PlacementPolicy has no replicas.
func (p PlacementPolicy) NumberOfReplicas() int { func (p PlacementPolicy) NumberOfReplicas() int {
return len(p.replicas) 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()). // descriptor. Index MUST be in range [0; NumberOfReplicas()).
// //
// Zero PlacementPolicy has no replicas. // Zero PlacementPolicy has no replicas.
func (p PlacementPolicy) ReplicaAmountByIndex(i int) uint32 { func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32 {
return p.replicas[i].GetCount() return p.replicas[i].GetCount()
} }
@ -178,11 +178,11 @@ func (s *Selector) SetName(name string) {
s.m.SetName(name) 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. // Zero Selector selects nothing.
func (s *Selector) SetNodeAmount(amount uint32) { func (s *Selector) SetNumberOfNodes(num uint32) {
s.m.SetCount(amount) s.m.SetCount(num)
} }
// SelectByBucketAttribute sets attribute of the bucket to select nodes from. // 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, // 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 '*'. // MUST NOT be '*'.
// //
// Zero Filter is unnamed. // Zero Filter is unnamed.

View file

@ -35,7 +35,7 @@ func (c *context) processSelectors(p PlacementPolicy) error {
return nil 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. // for the given selector.
func calcNodesCount(s netmap.Selector) (int, int) { func calcNodesCount(s netmap.Selector) (int, int) {
switch s.GetClause() { switch s.GetClause() {

View file

@ -254,15 +254,15 @@ func TestSelector_SetName(t *testing.T) {
require.Equal(t, name, s.m.GetName()) require.Equal(t, name, s.m.GetName())
} }
func TestSelector_SetNodeAmount(t *testing.T) { func TestSelector_SetNumberOfNodes(t *testing.T) {
const amount = 3 const num = 3
var s Selector var s Selector
require.Zero(t, s.m.GetCount()) 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) { func TestSelectorClauses(t *testing.T) {

View file

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