Documentation ¶
Overview ¶
Package netmap provides functionality for working with information about the NeoFS network, primarily a layer of storage nodes.
The package concentrates all the characteristics of NeoFS networks.
NetMap represents NeoFS network map - one of the main technologies used to store data in the system. It is composed of information about all storage nodes (NodeInfo type) in a particular network. NetMap methods allow you to impose container storage policies (PlacementPolicy type) on a fixed composition of nodes for selecting nodes corresponding to the placement rules chosen by the container creator.
NetworkInfo type is dedicated to descriptive characterization of network state and settings.
Index ¶
- func IterateNetworkEndpoints(node NodeInfo, f func(string))
- func StringifyPublicKey(node NodeInfo) string
- type Filter
- func (x *Filter) Equal(key, value string)
- func (x Filter) Key() string
- func (x *Filter) LogicalAND(filters ...Filter)
- func (x *Filter) LogicalOR(filters ...Filter)
- func (x Filter) Name() string
- func (x *Filter) NotEqual(key, value string)
- func (x *Filter) NumericGE(key string, num int64)
- func (x *Filter) NumericGT(key string, num int64)
- func (x *Filter) NumericLE(key string, num int64)
- func (x *Filter) NumericLT(key string, num int64)
- func (x Filter) Op() FilterOp
- func (x *Filter) SetName(name string)
- func (x Filter) SubFilters() []Filter
- func (x Filter) Value() string
- type FilterOp
- type NetMap
- func (m NetMap) ContainerNodes(p PlacementPolicy, containerID cid.ID) ([][]NodeInfo, error)
- func (m NetMap) Epoch() uint64
- func (m NetMap) Nodes() []NodeInfo
- func (m NetMap) PlacementVectors(vectors [][]NodeInfo, objectID oid.ID) ([][]NodeInfo, error)
- func (m *NetMap) ReadFromV2(msg netmap.NetMap) error
- func (m *NetMap) SetEpoch(epoch uint64)
- func (m *NetMap) SetNodes(nodes []NodeInfo)
- func (m NetMap) WriteToV2(msg *netmap.NetMap)
- type NetworkInfo
- func (x *NetworkInfo) AllowMaintenanceMode()
- func (x NetworkInfo) AuditFee() uint64
- func (x NetworkInfo) ContainerFee() uint64
- func (x NetworkInfo) CurrentEpoch() uint64
- func (x *NetworkInfo) DisableHomomorphicHashing()
- func (x NetworkInfo) EigenTrustAlpha() float64
- func (x NetworkInfo) EpochDuration() uint64
- func (x NetworkInfo) HomomorphicHashingDisabled() bool
- func (x NetworkInfo) IRCandidateFee() uint64
- func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []byte))
- func (x NetworkInfo) MagicNumber() uint64
- func (x NetworkInfo) MaintenanceModeAllowed() bool
- func (x NetworkInfo) Marshal() []byte
- func (x NetworkInfo) MaxObjectSize() uint64
- func (x NetworkInfo) MsPerBlock() int64
- func (x NetworkInfo) NamedContainerFee() uint64
- func (x NetworkInfo) NumberOfEigenTrustIterations() uint64
- func (x *NetworkInfo) RawNetworkParameter(name string) []byte
- func (x *NetworkInfo) ReadFromV2(m netmap.NetworkInfo) error
- func (x *NetworkInfo) SetAuditFee(fee uint64)
- func (x *NetworkInfo) SetContainerFee(fee uint64)
- func (x *NetworkInfo) SetCurrentEpoch(epoch uint64)
- func (x *NetworkInfo) SetEigenTrustAlpha(alpha float64)
- func (x *NetworkInfo) SetEpochDuration(blocks uint64)
- func (x *NetworkInfo) SetIRCandidateFee(fee uint64)
- func (x *NetworkInfo) SetMagicNumber(epoch uint64)
- func (x *NetworkInfo) SetMaxObjectSize(sz uint64)
- func (x *NetworkInfo) SetMsPerBlock(v int64)
- func (x *NetworkInfo) SetNamedContainerFee(fee uint64)
- func (x *NetworkInfo) SetNumberOfEigenTrustIterations(num uint64)
- func (x *NetworkInfo) SetRawNetworkParameter(name string, value []byte)
- func (x *NetworkInfo) SetStoragePrice(price uint64)
- func (x *NetworkInfo) SetWithdrawalFee(sz uint64)
- func (x NetworkInfo) StoragePrice() uint64
- func (x *NetworkInfo) Unmarshal(data []byte) error
- func (x NetworkInfo) WithdrawalFee() uint64
- func (x NetworkInfo) WriteToV2(m *netmap.NetworkInfo)
- type NodeInfo
- func (x NodeInfo) Attribute(key string) string
- func (x NodeInfo) ContinentName() string
- func (x NodeInfo) CountryCode() string
- func (x NodeInfo) CountryName() string
- func (x NodeInfo) ExternalAddresses() []string
- func (x NodeInfo) Hash() uint64
- func (x NodeInfo) IsMaintenance() bool
- func (x NodeInfo) IsOffline() bool
- func (x NodeInfo) IsOnline() bool
- func (x NodeInfo) IterateAttributes(f func(key, value string))
- func (x NodeInfo) IterateNetworkEndpoints(f func(string) bool)
- func (x NodeInfo) LOCODE() string
- func (x NodeInfo) LocationName() string
- func (x NodeInfo) Marshal() []byte
- func (x NodeInfo) MarshalJSON() ([]byte, error)
- func (x NodeInfo) NumberOfAttributes() int
- func (x NodeInfo) NumberOfNetworkEndpoints() int
- func (x NodeInfo) Price() uint64
- func (x NodeInfo) PublicKey() []byte
- func (x *NodeInfo) ReadFromV2(m netmap.NodeInfo) error
- func (x *NodeInfo) SetAttribute(key, value string)
- func (x *NodeInfo) SetCapacity(capacity uint64)
- func (x *NodeInfo) SetContinentName(continent string)
- func (x *NodeInfo) SetCountryCode(countryCode string)
- func (x *NodeInfo) SetCountryName(country string)
- func (x *NodeInfo) SetExternalAddresses(addr ...string)
- func (x *NodeInfo) SetLOCODE(locode string)
- func (x *NodeInfo) SetLocationName(location string)
- func (x *NodeInfo) SetMaintenance()
- func (x *NodeInfo) SetNetworkEndpoints(v ...string)
- func (x *NodeInfo) SetOffline()
- func (x *NodeInfo) SetOnline()
- func (x *NodeInfo) SetPrice(price uint64)
- func (x *NodeInfo) SetPublicKey(key []byte)
- func (x *NodeInfo) SetSubdivisionCode(subDiv string)
- func (x *NodeInfo) SetSubdivisionName(subDiv string)
- func (x *NodeInfo) SetVerifiedNodesDomain(domain string)
- func (x *NodeInfo) SetVersion(version string)
- func (x *NodeInfo) SortAttributes()
- func (x NodeInfo) SubdivisionCode() string
- func (x NodeInfo) SubdivisionName() string
- func (x *NodeInfo) Unmarshal(data []byte) error
- func (x *NodeInfo) UnmarshalJSON(data []byte) error
- func (x NodeInfo) VerifiedNodesDomain() string
- func (x NodeInfo) WriteToV2(m *netmap.NodeInfo)
- type PlacementPolicy
- func (p *PlacementPolicy) ContainerBackupFactor() uint32
- func (p PlacementPolicy) CopyTo(dst *PlacementPolicy)
- func (p *PlacementPolicy) DecodeString(s string) error
- func (p PlacementPolicy) Filters() []Filter
- func (p PlacementPolicy) Marshal() []byte
- func (p PlacementPolicy) MarshalJSON() ([]byte, error)
- func (p PlacementPolicy) NumberOfReplicas() int
- func (p *PlacementPolicy) ReadFromV2(m netmap.PlacementPolicy) error
- func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32
- func (p PlacementPolicy) Replicas() []ReplicaDescriptor
- func (p PlacementPolicy) Selectors() []Selector
- func (p *PlacementPolicy) SetContainerBackupFactor(f uint32)
- func (p *PlacementPolicy) SetFilters(fs []Filter)
- func (p *PlacementPolicy) SetReplicas(rs []ReplicaDescriptor)
- func (p *PlacementPolicy) SetSelectors(ss []Selector)
- func (p *PlacementPolicy) Unmarshal(data []byte) error
- func (p *PlacementPolicy) UnmarshalJSON(data []byte) error
- func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error)
- func (p PlacementPolicy) WriteToV2(m *netmap.PlacementPolicy)
- type ReplicaDescriptor
- type Selector
- func (s *Selector) BucketAttribute() string
- func (s *Selector) FilterName() string
- func (s *Selector) IsDistinct() bool
- func (s *Selector) IsSame() bool
- func (s Selector) Name() string
- func (s Selector) NumberOfNodes() uint32
- func (s *Selector) SelectByBucketAttribute(bucket string)
- func (s *Selector) SelectDistinct()
- func (s *Selector) SelectSame()
- func (s *Selector) SetFilterName(f string)
- func (s *Selector) SetName(name string)
- func (s *Selector) SetNumberOfNodes(num uint32)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IterateNetworkEndpoints ¶
IterateNetworkEndpoints is an extra-sugared function over IterateNetworkEndpoints method which allows to unconditionally iterate over all node's network endpoints.
func StringifyPublicKey ¶
StringifyPublicKey returns HEX representation of PublicKey.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter contains rules for filtering the node sets.
func (*Filter) Equal ¶
Equal applies the rule to accept only nodes with the same attribute value.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) LogicalAND ¶
LogicalAND applies the rule to accept only nodes which satisfy all the given filters.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) LogicalOR ¶
LogicalOR applies the rule to accept only nodes which satisfy at least one of the given filters.
Method SHOULD NOT be called along with other similar methods.
func (Filter) Name ¶
Name returns name with which the Filter can be referenced or, for inner filters, to which the Filter references. Top-level filters MUST be named. The name MUST NOT be '*'.
Zero Filter is unnamed.
See also Filter.SetName.
func (*Filter) NotEqual ¶
NotEqual applies the rule to accept only nodes with the distinct attribute value.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericGE ¶
NumericGE applies the rule to accept only nodes with the numeric attribute greater than or equal to given number.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericGT ¶
NumericGT applies the rule to accept only nodes with the numeric attribute greater than given number.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericLE ¶
NumericLE applies the rule to accept only nodes with the numeric attribute less than or equal to given number.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) NumericLT ¶
NumericLT applies the rule to accept only nodes with the numeric attribute less than given number.
Method SHOULD NOT be called along with other similar methods.
func (*Filter) SetName ¶
SetName sets name with which the Filter can be referenced or, for inner filters, to which the Filter references. Top-level filters MUST be named. The name MUST NOT be '*'.
Zero Filter is unnamed.
See also Filter.Name.
func (Filter) SubFilters ¶
SubFilters returns list of sub-filters when Filter is complex.
type FilterOp ¶
type FilterOp uint32
FilterOp defines the matching property.
const ( FilterOpEQ FilterOp // String 'equal' FilterOpNE // String 'not equal' FilterOpGT // Numeric 'greater than' FilterOpGE // Numeric 'greater or equal than' FilterOpLT // Numeric 'less than' FilterOpLE // Numeric 'less or equal than' FilterOpOR // Logical disjunction FilterOpAND // Logical conjunction )
Supported FilterOp values.
type NetMap ¶
type NetMap struct {
// contains filtered or unexported fields
}
NetMap represents NeoFS network map. It includes information about all storage nodes registered in NeoFS the network.
NetMap is mutually compatible with github.com/epicchainlabs/epicchain-api-go/v2/netmap.NetMap message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (NetMap) ContainerNodes ¶
ContainerNodes returns two-dimensional list of nodes as a result of applying given PlacementPolicy to the NetMap. Each line of the list corresponds to a replica descriptor. Line order corresponds to order of ReplicaDescriptor list in the policy. Nodes are pre-filtered according to the Filter list from the policy, and then selected by Selector list. Result is not deterministic and node order in each vector may vary for call.
Result can be used in PlacementVectors.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (NetMap) Nodes ¶
Nodes returns nodes set using SetNodes.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (NetMap) PlacementVectors ¶
PlacementVectors sorts container nodes returned by ContainerNodes method and returns placement vectors for the entity identified by the given object id. 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 the fixed NetMap and parameters.
func (*NetMap) ReadFromV2 ¶
ReadFromV2 reads NetMap from the netmap.NetMap message. Checks if the message conforms to NeoFS API V2 protocol.
See also WriteToV2.
type NetworkInfo ¶
type NetworkInfo struct {
// contains filtered or unexported fields
}
NetworkInfo groups information about the NeoFS network state. Mainly used to describe the current state of the network.
NetworkInfo is mutually compatible with github.com/epicchainlabs/epicchain-api-go/v2/netmap.NetworkInfo message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (*NetworkInfo) AllowMaintenanceMode ¶
func (x *NetworkInfo) AllowMaintenanceMode()
AllowMaintenanceMode sets the flag allowing nodes to go into maintenance mode.
See also MaintenanceModeAllowed.
func (NetworkInfo) AuditFee ¶
func (x NetworkInfo) AuditFee() uint64
AuditFee returns audit fee set using SetAuditFee.
Zero NetworkInfo has zero audit fee.
func (NetworkInfo) ContainerFee ¶
func (x NetworkInfo) ContainerFee() uint64
ContainerFee returns container fee set using SetContainerFee.
Zero NetworkInfo has zero container fee.
func (NetworkInfo) CurrentEpoch ¶
func (x NetworkInfo) CurrentEpoch() uint64
CurrentEpoch returns epoch set using SetCurrentEpoch.
Zero NetworkInfo has zero current epoch.
func (*NetworkInfo) DisableHomomorphicHashing ¶
func (x *NetworkInfo) DisableHomomorphicHashing()
DisableHomomorphicHashing sets flag requiring to disable homomorphic hashing of the containers in the network.
See also HomomorphicHashingDisabled.
func (NetworkInfo) EigenTrustAlpha ¶
func (x NetworkInfo) EigenTrustAlpha() float64
EigenTrustAlpha returns EigenTrust parameter set using SetEigenTrustAlpha.
Zero NetworkInfo has zero alpha parameter.
func (NetworkInfo) EpochDuration ¶
func (x NetworkInfo) EpochDuration() uint64
EpochDuration returns epoch duration set using SetEpochDuration.
Zero NetworkInfo has zero iteration number.
func (NetworkInfo) HomomorphicHashingDisabled ¶
func (x NetworkInfo) HomomorphicHashingDisabled() bool
HomomorphicHashingDisabled returns the state of the homomorphic hashing network setting.
Zero NetworkInfo has enabled homomorphic hashing.
func (NetworkInfo) IRCandidateFee ¶
func (x NetworkInfo) IRCandidateFee() uint64
IRCandidateFee returns IR entrance fee set using SetIRCandidateFee.
Zero NetworkInfo has zero fee.
func (*NetworkInfo) IterateRawNetworkParameters ¶
func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []byte))
IterateRawNetworkParameters iterates over all raw networks parameters set using SetRawNetworkParameter and passes them into f.
Handler MUST NOT be nil. Handler MUST NOT mutate value parameter.
Zero NetworkInfo has no network parameters.
func (NetworkInfo) MagicNumber ¶
func (x NetworkInfo) MagicNumber() uint64
MagicNumber returns magic number set using SetMagicNumber.
Zero NetworkInfo has zero magic.
func (NetworkInfo) MaintenanceModeAllowed ¶
func (x NetworkInfo) MaintenanceModeAllowed() bool
MaintenanceModeAllowed returns true iff network config allows maintenance mode for storage nodes.
Zero NetworkInfo has disallows maintenance mode.
func (NetworkInfo) Marshal ¶
func (x NetworkInfo) Marshal() []byte
Marshal encodes NetworkInfo into a binary format of the NeoFS API protocol (Protocol Buffers with direct field order).
See also Unmarshal.
func (NetworkInfo) MaxObjectSize ¶
func (x NetworkInfo) MaxObjectSize() uint64
MaxObjectSize returns maximum object size set using SetMaxObjectSize.
Zero NetworkInfo has zero maximum size.
func (NetworkInfo) MsPerBlock ¶
func (x NetworkInfo) MsPerBlock() int64
MsPerBlock returns network parameter set using SetMsPerBlock.
func (NetworkInfo) NamedContainerFee ¶
func (x NetworkInfo) NamedContainerFee() uint64
NamedContainerFee returns container fee set using SetNamedContainerFee.
Zero NetworkInfo has zero container fee.
func (NetworkInfo) NumberOfEigenTrustIterations ¶
func (x NetworkInfo) NumberOfEigenTrustIterations() uint64
NumberOfEigenTrustIterations returns number of EigenTrust iterations set using SetNumberOfEigenTrustIterations.
Zero NetworkInfo has zero iteration number.
func (*NetworkInfo) RawNetworkParameter ¶
func (x *NetworkInfo) RawNetworkParameter(name string) []byte
RawNetworkParameter reads raw network parameter set using NetworkInfo.SetRawNetworkParameter by its name. Returns nil if value is missing.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
Zero NetworkInfo has no network parameters.
func (*NetworkInfo) ReadFromV2 ¶
func (x *NetworkInfo) ReadFromV2(m netmap.NetworkInfo) error
ReadFromV2 reads NetworkInfo from the netmap.NetworkInfo message. Checks if the message conforms to NeoFS API V2 protocol.
See also WriteToV2.
func (*NetworkInfo) SetAuditFee ¶
func (x *NetworkInfo) SetAuditFee(fee uint64)
SetAuditFee sets the configuration value of the audit fee for the Inner Ring.
See also AuditFee.
func (*NetworkInfo) SetContainerFee ¶
func (x *NetworkInfo) SetContainerFee(fee uint64)
SetContainerFee sets fee for the container creation that creator pays to each Alphabet node.
See also ContainerFee.
func (*NetworkInfo) SetCurrentEpoch ¶
func (x *NetworkInfo) SetCurrentEpoch(epoch uint64)
SetCurrentEpoch sets current epoch of the NeoFS network.
func (*NetworkInfo) SetEigenTrustAlpha ¶
func (x *NetworkInfo) SetEigenTrustAlpha(alpha float64)
SetEigenTrustAlpha sets alpha parameter for EigenTrust algorithm used in reputation system of the storage nodes. Value MUST be in range [0, 1].
See also EigenTrustAlpha.
func (*NetworkInfo) SetEpochDuration ¶
func (x *NetworkInfo) SetEpochDuration(blocks uint64)
SetEpochDuration sets NeoFS epoch duration measured in number of blocks of the NeoFS Sidechain.
See also EpochDuration.
func (*NetworkInfo) SetIRCandidateFee ¶
func (x *NetworkInfo) SetIRCandidateFee(fee uint64)
SetIRCandidateFee sets fee for Inner Ring entrance paid by a new member.
See also IRCandidateFee.
func (*NetworkInfo) SetMagicNumber ¶
func (x *NetworkInfo) SetMagicNumber(epoch uint64)
SetMagicNumber sets magic number of the NeoFS Sidechain.
See also MagicNumber.
func (*NetworkInfo) SetMaxObjectSize ¶
func (x *NetworkInfo) SetMaxObjectSize(sz uint64)
SetMaxObjectSize sets maximum size of the object stored locally on the storage nodes (physical objects). Binary representation of any physically stored object MUST NOT overflow the limit.
See also MaxObjectSize.
func (*NetworkInfo) SetMsPerBlock ¶
func (x *NetworkInfo) SetMsPerBlock(v int64)
SetMsPerBlock sets MillisecondsPerBlock network parameter of the NeoFS Sidechain.
See also MsPerBlock.
func (*NetworkInfo) SetNamedContainerFee ¶
func (x *NetworkInfo) SetNamedContainerFee(fee uint64)
SetNamedContainerFee sets fee for creation of the named container creation that creator pays to each Alphabet node.
See also NamedContainerFee.
func (*NetworkInfo) SetNumberOfEigenTrustIterations ¶
func (x *NetworkInfo) SetNumberOfEigenTrustIterations(num uint64)
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 NumberOfEigenTrustIterations.
func (*NetworkInfo) SetRawNetworkParameter ¶
func (x *NetworkInfo) SetRawNetworkParameter(name string, value []byte)
SetRawNetworkParameter sets named NeoFS network parameter whose value is transmitted but not interpreted by the NeoFS API protocol.
Argument MUST NOT be mutated, make a copy first.
See also RawNetworkParameter, IterateRawNetworkParameters.
func (*NetworkInfo) SetStoragePrice ¶
func (x *NetworkInfo) SetStoragePrice(price uint64)
SetStoragePrice sets the price per gigabyte of data storage that data owners pay to storage nodes.
See also StoragePrice.
func (*NetworkInfo) SetWithdrawalFee ¶
func (x *NetworkInfo) SetWithdrawalFee(sz uint64)
SetWithdrawalFee sets fee for withdrawals from the NeoFS accounts that account owners pay to each Alphabet node.
See also WithdrawalFee.
func (NetworkInfo) StoragePrice ¶
func (x NetworkInfo) StoragePrice() uint64
StoragePrice returns storage price set using SetStoragePrice.
Zero NetworkInfo has zero storage price.
func (*NetworkInfo) Unmarshal ¶
func (x *NetworkInfo) Unmarshal(data []byte) error
Unmarshal decodes NeoFS API protocol binary format into the NetworkInfo (Protocol Buffers with direct field order). Returns an error describing a format violation.
See also Marshal.
func (NetworkInfo) WithdrawalFee ¶
func (x NetworkInfo) WithdrawalFee() uint64
WithdrawalFee returns withdrawal fee set using SetWithdrawalFee.
Zero NetworkInfo has zero fee.
func (NetworkInfo) WriteToV2 ¶
func (x NetworkInfo) WriteToV2(m *netmap.NetworkInfo)
WriteToV2 writes NetworkInfo to the netmap.NetworkInfo message. The message MUST NOT be nil.
See also ReadFromV2.
type NodeInfo ¶
type NodeInfo struct {
// contains filtered or unexported fields
}
NodeInfo groups information about NeoFS storage node which is reflected in the NeoFS network map. Storage nodes advertise this information when registering with the NeoFS network. After successful registration, information about the nodes is available to all network participants to work with the network map (mainly to comply with container storage policies).
NodeInfo is mutually compatible with github.com/epicchainlabs/epicchain-api-go/v2/netmap.NodeInfo message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
Example (Marshalling) ¶
Instances can be also used to process NeoFS API V2 protocol messages with [https://github.com/nspcc-dev/neofs-api] package.
package main import ( apiGoNetmap "github.com/epicchainlabs/epicchain-api-go/v2/netmap" "github.com/epicchainlabs/epicchain-sdk-go/netmap" ) func main() { // import apiGoNetmap "github.com/epicchainlabs/epicchain-api-go/v2/netmap" // On the client side. var info netmap.NodeInfo var msg apiGoNetmap.NodeInfo info.WriteToV2(&msg) // *send message* // On the server side. _ = info.ReadFromV2(msg) }
Output:
func (NodeInfo) Attribute ¶
Attribute returns value of the node attribute set using SetAttribute by the given key. Returns empty string if attribute is missing.
func (NodeInfo) ContinentName ¶
ContinentName returns node's continent set using SetContinentName.
Zero NodeInfo has continent which is invalid according to NeoFS API system requirement.
func (NodeInfo) CountryCode ¶
CountryCode returns node's country code set using SetCountryCode.
Zero NodeInfo has empty country code which is invalid according to NeoFS API system requirement.
func (NodeInfo) CountryName ¶
CountryName returns node's country name set using SetCountryName.
Zero NodeInfo has empty country name which is invalid according to NeoFS API system requirement.
func (NodeInfo) ExternalAddresses ¶
ExternalAddresses returns list of multi-addresses to use to connect to this node from outside.
func (NodeInfo) Hash ¶
Hash implements hrw.Hasher interface.
Hash is needed to support weighted HRW therefore sort function sorts nodes based on their public key. Hash isn't expected to be used directly.
func (NodeInfo) IsMaintenance ¶
IsMaintenance checks if the node is in the "maintenance" state.
Zero NodeInfo has undefined state.
See also SetMaintenance.
func (NodeInfo) IsOffline ¶
IsOffline checks if the node is in the "offline" state.
Zero NodeInfo has undefined state which is not offline (note that it does not mean online).
See also SetOffline.
func (NodeInfo) IsOnline ¶
IsOnline checks if the node is in the "online" state.
Zero NodeInfo has undefined state which is not online (note that it does not mean offline).
See also SetOnline.
func (NodeInfo) IterateAttributes ¶
IterateAttributes iterates over all node attributes and passes the into f. Handler MUST NOT be nil.
func (NodeInfo) IterateNetworkEndpoints ¶
IterateNetworkEndpoints iterates over network endpoints announced by the node and pass them into f. Breaks iteration on f's true return. Handler MUST NOT be nil.
Zero NodeInfo contains no endpoints which is incorrect according to NeoFS system requirements.
See also SetNetworkEndpoints.
func (NodeInfo) LOCODE ¶
LOCODE returns node's location code set using SetLOCODE.
Zero NodeInfo has empty location code which is invalid according to NeoFS API system requirement.
func (NodeInfo) LocationName ¶
LocationName returns node's location set using SetLocationName.
Zero NodeInfo has empty location which is invalid according to NeoFS API system requirement.
func (NodeInfo) Marshal ¶
Marshal encodes NodeInfo into a binary format of the NeoFS API protocol (Protocol Buffers with direct field order).
See also Unmarshal.
func (NodeInfo) MarshalJSON ¶
MarshalJSON encodes NodeInfo into a JSON format of the NeoFS API protocol (Protocol Buffers JSON).
See also UnmarshalJSON.
func (NodeInfo) NumberOfAttributes ¶
NumberOfAttributes returns number of attributes announced by the node.
See also SetAttribute.
func (NodeInfo) NumberOfNetworkEndpoints ¶
NumberOfNetworkEndpoints returns number of network endpoints announced by the node.
See also SetNetworkEndpoints.
func (NodeInfo) PublicKey ¶
PublicKey returns value set using NodeInfo.SetPublicKey.
Zero NodeInfo has no public key, which is incorrect according to NeoFS system requirements.
The resulting slice of bytes is a serialized compressed public key. See [elliptic.MarshalCompressed]. Use [neofsecdsa.PublicKey.Decode] to decode it into a type-specific structure.
The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.
func (*NodeInfo) ReadFromV2 ¶
ReadFromV2 reads NodeInfo from the netmap.NodeInfo message. Checks if the message conforms to NeoFS API V2 protocol.
See also WriteToV2.
func (*NodeInfo) SetAttribute ¶
SetAttribute sets value of the node attribute value by the given key. Both key and value MUST NOT be empty.
func (*NodeInfo) SetCapacity ¶
SetCapacity sets the storage capacity declared by the node. By default, zero capacity is announced.
func (*NodeInfo) SetContinentName ¶
SetContinentName sets name of the storage node's continent from Seven-Continent model.
func (*NodeInfo) SetCountryCode ¶
SetCountryCode sets code of the country in ISO 3166-1_alpha-2 to which storage node belongs (or the closest one).
func (*NodeInfo) SetCountryName ¶
SetCountryName sets short name of the country in ISO-3166 format to which storage node belongs (or the closest one).
func (*NodeInfo) SetExternalAddresses ¶
SetExternalAddresses sets multi-addresses to use to connect to this node from outside.
Panics if addr is an empty list.
func (*NodeInfo) SetLOCODE ¶
SetLOCODE specifies node's geographic location in UN/LOCODE format. Each storage node MUST declare it for entrance to the NeoFS network. Node MAY declare the code of the nearest location as needed, for example, when it is impossible to unambiguously attribute the node to any location from UN/LOCODE database.
See also LOCODE.
func (*NodeInfo) SetLocationName ¶
SetLocationName sets storage node's location name from "NameWoDiacritics" column in the UN/LOCODE record corresponding to the specified LOCODE.
func (*NodeInfo) SetMaintenance ¶
func (x *NodeInfo) SetMaintenance()
SetMaintenance sets the state of the node to "maintenance". When a node updates information about itself in the network map, this state declares temporal unavailability for a node.
See also IsMaintenance.
func (*NodeInfo) SetNetworkEndpoints ¶
SetNetworkEndpoints sets list to the announced node's network endpoints. Node MUSt have at least one announced endpoint. List MUST be unique. Endpoints are used for communication with the storage node within NeoFS network. It is expected that node serves storage node services on these endpoints (it also adds a wait on their network availability).
Argument MUST NOT be mutated, make a copy first.
See also IterateNetworkEndpoints.
func (*NodeInfo) SetOffline ¶
func (x *NodeInfo) SetOffline()
SetOffline sets the state of the node to "offline". When a node updates information about itself in the network map, this action is interpreted as an intention to leave the network.
func (*NodeInfo) SetOnline ¶
func (x *NodeInfo) SetOnline()
SetOnline sets the state of the node to "online". When a node updates information about itself in the network map, this action is interpreted as an intention to enter the network.
See also IsOnline.
func (*NodeInfo) SetPrice ¶
SetPrice sets the storage cost declared by the node. By default, zero price is announced.
func (*NodeInfo) SetPublicKey ¶
SetPublicKey sets binary-encoded public key bound to the node. The key authenticates the storage node, so it MUST be unique within the network.
Argument MUST NOT be mutated, make a copy first.
The key parameter is a serialized compressed public key. See [elliptic.MarshalCompressed].
See also NodeInfo.PublicKey.
func (*NodeInfo) SetSubdivisionCode ¶
SetSubdivisionCode sets storage node's subdivision code from "SubDiv" column in the UN/LOCODE record corresponding to the specified LOCODE.
func (*NodeInfo) SetSubdivisionName ¶
SetSubdivisionName sets storage node's subdivision name in ISO 3166-2 format.
func (*NodeInfo) SetVerifiedNodesDomain ¶
SetVerifiedNodesDomain sets optional NeoFS NNS domain name to be used to confirm admission to a storage nodes' group on registration in the NeoFS network of a storage node submitting this NodeInfo about itself. If domain is specified, the storage node requesting entry into the NeoFS network map with must be included in the access list located on the specified domain. The access list is represented by a set of TXT records: Neo script hashes from public keys. To be admitted to the network, script hash of the NodeInfo.PublicKey must be present in domain records. Otherwise, registration will be denied. By default, this check is not carried out.
Value MUST be a valid NeoFS NNS domain name.
See also NodeInfo.VerifiedNodesDomain.
Example ¶
When forming information about storage node to be registered the NeoFS network, the node may be optionally associated with some private group of storage nodes in the network. The groups are managed by their owners in corresponding NeoFS NNS domains.
package main import ( "fmt" "github.com/epicchainlabs/epicchain-sdk-go/netmap" ) func main() { var bNodePublicKey []byte var n netmap.NodeInfo n.SetPublicKey(bNodePublicKey) // other info n.SetVerifiedNodesDomain("nodes.some-org.neofs") // to be allowed into the network, set public key must be in the access list // managed in the specified domain // the specified domain is later processed by the system fmt.Printf("Verified nodes' domain: %s\n", n.VerifiedNodesDomain()) }
Output:
func (*NodeInfo) SetVersion ¶
SetVersion sets node's version. By default, version is not announced.
func (*NodeInfo) SortAttributes ¶
func (x *NodeInfo) SortAttributes()
SortAttributes sorts node attributes set using SetAttribute lexicographically. The method is only needed to make NodeInfo consistent, e.g. for signing.
func (NodeInfo) SubdivisionCode ¶
SubdivisionCode returns node's subdivision code set using SetSubdivisionCode.
Zero NodeInfo has subdivision code which is invalid according to NeoFS API system requirement.
func (NodeInfo) SubdivisionName ¶
SubdivisionName returns node's subdivision name set using SetSubdivisionName.
Zero NodeInfo has subdivision name which is invalid according to NeoFS API system requirement.
func (*NodeInfo) Unmarshal ¶
Unmarshal decodes NeoFS API protocol binary format into the NodeInfo (Protocol Buffers with direct field order). Returns an error describing a format violation.
See also Marshal.
func (*NodeInfo) UnmarshalJSON ¶
UnmarshalJSON decodes NeoFS API protocol JSON format into the NodeInfo (Protocol Buffers JSON). Returns an error describing a format violation.
See also MarshalJSON.
func (NodeInfo) VerifiedNodesDomain ¶
VerifiedNodesDomain returns optional NeoFS NNS domain name to be used to confirm admission to a storage nodes' group on registration in the NeoFS network of a storage node submitting this NodeInfo about itself. Returns zero value if domain is not specified.
See also NodeInfo.SetVerifiedNodesDomain.
type PlacementPolicy ¶
type PlacementPolicy struct {
// contains filtered or unexported fields
}
PlacementPolicy declares policy to store objects in the NeoFS container. Within itself, PlacementPolicy represents a set of rules to select a subset of nodes from NeoFS network map - node-candidates for object storage.
PlacementPolicy is mutually compatible with github.com/epicchainlabs/epicchain-api-go/v2/netmap.PlacementPolicy message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (*PlacementPolicy) ContainerBackupFactor ¶
func (p *PlacementPolicy) ContainerBackupFactor() uint32
ContainerBackupFactor returns container backup factor: it controls how deep NeoFS will search for nodes alternatives to include into container's nodes subset.
Zero PlacementPolicy has zero container backup factor.
See also PlacementPolicy.SetContainerBackupFactor.
func (PlacementPolicy) CopyTo ¶
func (p PlacementPolicy) CopyTo(dst *PlacementPolicy)
CopyTo writes deep copy of the PlacementPolicy to dst.
func (*PlacementPolicy) DecodeString ¶
func (p *PlacementPolicy) DecodeString(s string) error
DecodeString decodes PlacementPolicy from the string composed using WriteStringTo. Returns error if s is malformed.
func (PlacementPolicy) Filters ¶
func (p PlacementPolicy) Filters() []Filter
Filters returns list of Filter that will be applied when selecting nodes.
Zero PlacementPolicy has no filters.
See also PlacementPolicy.SetFilters.
func (PlacementPolicy) Marshal ¶
func (p PlacementPolicy) Marshal() []byte
Marshal encodes PlacementPolicy into a binary format of the NeoFS API protocol (Protocol Buffers with direct field order).
See also Unmarshal.
func (PlacementPolicy) MarshalJSON ¶
func (p PlacementPolicy) MarshalJSON() ([]byte, error)
MarshalJSON encodes PlacementPolicy into a JSON format of the NeoFS API protocol (Protocol Buffers JSON).
See also UnmarshalJSON.
func (PlacementPolicy) NumberOfReplicas ¶
func (p PlacementPolicy) NumberOfReplicas() int
NumberOfReplicas returns number of replica descriptors set using SetReplicas.
Zero PlacementPolicy has no replicas which is incorrect according to the NeoFS API protocol.
func (*PlacementPolicy) ReadFromV2 ¶
func (p *PlacementPolicy) ReadFromV2(m netmap.PlacementPolicy) error
ReadFromV2 reads PlacementPolicy from the netmap.PlacementPolicy message. Checks if the message conforms to NeoFS API V2 protocol.
See also WriteToV2.
func (PlacementPolicy) ReplicaNumberByIndex ¶
func (p PlacementPolicy) ReplicaNumberByIndex(i int) uint32
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 (PlacementPolicy) Replicas ¶
func (p PlacementPolicy) Replicas() []ReplicaDescriptor
Replicas returns list of object replica characteristics.
See also PlacementPolicy.SetReplicas, PlacementPolicy.NumberOfReplicas, PlacementPolicy.ReplicaNumberByIndex.
func (PlacementPolicy) Selectors ¶
func (p PlacementPolicy) Selectors() []Selector
Selectors returns list of Selector to form the subset of the nodes to store container objects.
Zero PlacementPolicy does not declare selectors.
See also PlacementPolicy.SetSelectors.
func (*PlacementPolicy) SetContainerBackupFactor ¶
func (p *PlacementPolicy) SetContainerBackupFactor(f uint32)
SetContainerBackupFactor sets container backup factor: it controls how deep NeoFS will search for nodes alternatives to include into container's nodes subset.
Zero PlacementPolicy has zero container backup factor.
See also PlacementPolicy.ContainerBackupFactor.
func (*PlacementPolicy) SetFilters ¶
func (p *PlacementPolicy) SetFilters(fs []Filter)
SetFilters sets list of Filter that will be applied when selecting nodes.
Zero PlacementPolicy has no filters.
See also PlacementPolicy.Filters.
func (*PlacementPolicy) SetReplicas ¶
func (p *PlacementPolicy) SetReplicas(rs []ReplicaDescriptor)
SetReplicas sets list of object replica's characteristics.
See also PlacementPolicy.Replicas, PlacementPolicy.NumberOfReplicas, PlacementPolicy.ReplicaNumberByIndex.
func (*PlacementPolicy) SetSelectors ¶
func (p *PlacementPolicy) SetSelectors(ss []Selector)
SetSelectors sets list of Selector to form the subset of the nodes to store container objects.
Zero PlacementPolicy does not declare selectors.
See also PlacementPolicy.Selectors.
func (*PlacementPolicy) Unmarshal ¶
func (p *PlacementPolicy) Unmarshal(data []byte) error
Unmarshal decodes NeoFS API protocol binary format into the PlacementPolicy (Protocol Buffers with direct field order). Returns an error describing a format violation.
See also Marshal.
func (*PlacementPolicy) UnmarshalJSON ¶
func (p *PlacementPolicy) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes NeoFS API protocol JSON format into the PlacementPolicy (Protocol Buffers JSON). Returns an error describing a format violation.
See also MarshalJSON.
func (PlacementPolicy) WriteStringTo ¶
func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error)
WriteStringTo encodes PlacementPolicy into human-readably query and writes the result into w. Returns w's errors directly.
See also DecodeString.
func (PlacementPolicy) WriteToV2 ¶
func (p PlacementPolicy) WriteToV2(m *netmap.PlacementPolicy)
WriteToV2 writes PlacementPolicy to the session.Token message. The message must not be nil.
See also ReadFromV2.
type ReplicaDescriptor ¶
type ReplicaDescriptor struct {
// contains filtered or unexported fields
}
ReplicaDescriptor replica descriptor characterizes replicas of objects from the subset selected by a particular Selector.
func (ReplicaDescriptor) NumberOfObjects ¶
func (r ReplicaDescriptor) NumberOfObjects() uint32
NumberOfObjects returns number set using SetNumberOfObjects.
Zero ReplicaDescriptor has zero number of objects.
func (ReplicaDescriptor) SelectorName ¶
func (r ReplicaDescriptor) SelectorName() string
SelectorName returns name of the related Selector.
Zero ReplicaDescriptor references to the root bucket's selector: it contains all possible nodes to store the object.
See also ReplicaDescriptor.SetSelectorName.
func (*ReplicaDescriptor) SetNumberOfObjects ¶
func (r *ReplicaDescriptor) SetNumberOfObjects(c uint32)
SetNumberOfObjects sets number of object replicas.
func (*ReplicaDescriptor) SetSelectorName ¶
func (r *ReplicaDescriptor) SetSelectorName(s string)
SetSelectorName sets name of the related Selector.
Zero ReplicaDescriptor references to the root bucket's selector: it contains all possible nodes to store the object.
See also ReplicaDescriptor.SelectorName.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector describes the bucket selection operator: choose a number of nodes from the bucket taking the nearest nodes to the related container by hash distance.
func (*Selector) BucketAttribute ¶
BucketAttribute returns attribute of the bucket to select nodes from.
Zero Selector has empty attribute.
See also Selector.SelectByBucketAttribute.
func (*Selector) FilterName ¶
FilterName returns reference to pre-filtering nodes for selection.
Zero Selector has no filtering reference.
See also Filter.SetName, Selector.SetFilterName.
func (*Selector) IsDistinct ¶
IsDistinct checks whether selection algorithm is set to select only nodes having the different values of the bucket attribute.
See also Selector.SelectByBucketAttribute, Selector.SelectDistinct.
func (*Selector) IsSame ¶
IsSame checks whether selection algorithm is set to select only nodes having the same values of the bucket attribute.
See also Selector.SelectSame.
func (Selector) Name ¶
Name returns name with which the Selector can be referenced.
Zero Selector is unnamed.
See also Selector.Name.
func (Selector) NumberOfNodes ¶
NumberOfNodes returns number of nodes to select from the bucket.
Zero Selector selects nothing.
See also Selector.SetNumberOfNodes.
func (*Selector) SelectByBucketAttribute ¶
SelectByBucketAttribute sets attribute of the bucket to select nodes from.
Zero Selector has empty attribute.
See also Selector.BucketAttribute.
func (*Selector) SelectDistinct ¶
func (s *Selector) SelectDistinct()
SelectDistinct makes selection algorithm to select only nodes having the different values of the bucket attribute.
Zero Selector doesn't specify selection modifier so nodes are selected randomly.
See also Selector.SelectByBucketAttribute, Selector.IsDistinct.
func (*Selector) SelectSame ¶
func (s *Selector) SelectSame()
SelectSame makes selection algorithm to select only nodes having the same values of the bucket attribute.
Zero Selector doesn't specify selection modifier so nodes are selected randomly.
See also Selector.SelectByBucketAttribute, Selector.IsSame.
func (*Selector) SetFilterName ¶
SetFilterName sets reference to pre-filtering nodes for selection.
Zero Selector has no filtering reference.
See also Filter.SetName.
func (*Selector) SetName ¶
SetName sets name with which the Selector can be referenced.
Zero Selector is unnamed.
func (*Selector) SetNumberOfNodes ¶
SetNumberOfNodes sets number of nodes to select from the bucket.
Zero Selector selects nothing.
See also Selector.NumberOfNodes.