2020-08-17 11:48:08 +00:00
|
|
|
package netmap
|
|
|
|
|
2020-10-08 11:22:28 +00:00
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
|
|
)
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
type LocalNodeInfoRequest struct {
|
|
|
|
body *LocalNodeInfoRequestBody
|
|
|
|
|
|
|
|
session.RequestHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
type LocalNodeInfoResponse struct {
|
|
|
|
body *LocalNodeInfoResponseBody
|
|
|
|
|
|
|
|
session.ResponseHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkInfoRequest is a structure of NetworkInfo request.
|
|
|
|
type NetworkInfoRequest struct {
|
|
|
|
body *NetworkInfoRequestBody
|
|
|
|
|
|
|
|
session.RequestHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkInfoResponse is a structure of NetworkInfo response.
|
|
|
|
type NetworkInfoResponse struct {
|
|
|
|
body *NetworkInfoResponseBody
|
|
|
|
|
|
|
|
session.ResponseHeaders
|
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
type Filter struct {
|
|
|
|
name string
|
|
|
|
key string
|
|
|
|
op Operation
|
|
|
|
value string
|
2022-03-01 13:41:42 +00:00
|
|
|
filters []Filter
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Selector struct {
|
|
|
|
name string
|
|
|
|
count uint32
|
2020-09-08 10:19:22 +00:00
|
|
|
clause Clause
|
2020-09-04 10:05:56 +00:00
|
|
|
attribute string
|
|
|
|
filter string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Replica struct {
|
|
|
|
count uint32
|
|
|
|
selector string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Operation uint32
|
|
|
|
|
2020-08-17 11:48:08 +00:00
|
|
|
type PlacementPolicy struct {
|
2022-03-01 13:41:42 +00:00
|
|
|
replicas []Replica
|
2020-09-04 10:05:56 +00:00
|
|
|
backupFactor uint32
|
2022-03-01 13:41:42 +00:00
|
|
|
selectors []Selector
|
|
|
|
filters []Filter
|
2021-11-17 13:58:38 +00:00
|
|
|
subnetID *refs.SubnetID
|
2020-08-17 11:48:08 +00:00
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
|
|
|
// Attribute of storage node.
|
|
|
|
type Attribute struct {
|
2020-09-04 10:05:56 +00:00
|
|
|
key string
|
|
|
|
value string
|
|
|
|
parents []string
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NodeInfo of storage node.
|
|
|
|
type NodeInfo struct {
|
|
|
|
publicKey []byte
|
2021-06-18 16:08:55 +00:00
|
|
|
addresses []string
|
2022-03-02 07:40:22 +00:00
|
|
|
attributes []Attribute
|
2020-09-04 10:05:56 +00:00
|
|
|
state NodeState
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NodeState of storage node.
|
|
|
|
type NodeState uint32
|
|
|
|
|
2020-09-08 10:19:22 +00:00
|
|
|
// Clause of placement selector.
|
|
|
|
type Clause uint32
|
|
|
|
|
2020-10-08 11:22:28 +00:00
|
|
|
type LocalNodeInfoRequestBody struct{}
|
|
|
|
|
|
|
|
type LocalNodeInfoResponseBody struct {
|
|
|
|
version *refs.Version
|
|
|
|
nodeInfo *NodeInfo
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
const (
|
2020-09-04 10:05:56 +00:00
|
|
|
UnspecifiedState NodeState = iota
|
2020-09-01 07:46:20 +00:00
|
|
|
Online
|
|
|
|
Offline
|
2022-09-15 05:21:44 +00:00
|
|
|
Maintenance
|
2020-09-01 07:46:20 +00:00
|
|
|
)
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
const (
|
|
|
|
UnspecifiedOperation Operation = iota
|
|
|
|
EQ
|
|
|
|
NE
|
|
|
|
GT
|
|
|
|
GE
|
|
|
|
LT
|
|
|
|
LE
|
|
|
|
OR
|
|
|
|
AND
|
|
|
|
)
|
|
|
|
|
2020-09-08 10:19:22 +00:00
|
|
|
const (
|
|
|
|
UnspecifiedClause Clause = iota
|
|
|
|
Same
|
|
|
|
Distinct
|
|
|
|
)
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (f *Filter) GetFilters() []Filter {
|
2020-09-04 10:05:56 +00:00
|
|
|
if f != nil {
|
|
|
|
return f.filters
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (f *Filter) SetFilters(filters []Filter) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.filters = filters
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) GetValue() string {
|
|
|
|
if f != nil {
|
|
|
|
return f.value
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) SetValue(value string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.value = value
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) GetOp() Operation {
|
|
|
|
if f != nil {
|
|
|
|
return f.op
|
|
|
|
}
|
|
|
|
return UnspecifiedOperation
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) SetOp(op Operation) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.op = op
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) GetKey() string {
|
|
|
|
if f != nil {
|
|
|
|
return f.key
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) SetKey(key string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.key = key
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) GetName() string {
|
|
|
|
if f != nil {
|
|
|
|
return f.name
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filter) SetName(name string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
f.name = name
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) GetFilter() string {
|
|
|
|
if s != nil {
|
|
|
|
return s.filter
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) SetFilter(filter string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
s.filter = filter
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) GetAttribute() string {
|
|
|
|
if s != nil {
|
|
|
|
return s.attribute
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) SetAttribute(attribute string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
s.attribute = attribute
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-08 10:19:22 +00:00
|
|
|
func (s *Selector) GetClause() Clause {
|
|
|
|
if s != nil {
|
|
|
|
return s.clause
|
|
|
|
}
|
|
|
|
|
|
|
|
return UnspecifiedClause
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) SetClause(clause Clause) {
|
2022-03-23 11:42:57 +00:00
|
|
|
s.clause = clause
|
2020-09-08 10:19:22 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
func (s *Selector) GetCount() uint32 {
|
|
|
|
if s != nil {
|
|
|
|
return s.count
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) SetCount(count uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
s.count = count
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) GetName() string {
|
|
|
|
if s != nil {
|
|
|
|
return s.name
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) SetName(name string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
s.name = name
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Replica) GetSelector() string {
|
|
|
|
if r != nil {
|
|
|
|
return r.selector
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Replica) SetSelector(selector string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.selector = selector
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Replica) GetCount() uint32 {
|
|
|
|
if r != nil {
|
|
|
|
return r.count
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Replica) SetCount(count uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.count = count
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (p *PlacementPolicy) GetFilters() []Filter {
|
2020-09-04 10:05:56 +00:00
|
|
|
if p != nil {
|
|
|
|
return p.filters
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (p *PlacementPolicy) SetFilters(filters []Filter) {
|
2022-03-23 11:42:57 +00:00
|
|
|
p.filters = filters
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (p *PlacementPolicy) GetSelectors() []Selector {
|
2020-09-04 10:05:56 +00:00
|
|
|
if p != nil {
|
|
|
|
return p.selectors
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (p *PlacementPolicy) SetSelectors(selectors []Selector) {
|
2022-03-23 11:42:57 +00:00
|
|
|
p.selectors = selectors
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PlacementPolicy) GetContainerBackupFactor() uint32 {
|
|
|
|
if p != nil {
|
|
|
|
return p.backupFactor
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PlacementPolicy) SetContainerBackupFactor(backupFactor uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
p.backupFactor = backupFactor
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (p *PlacementPolicy) GetReplicas() []Replica {
|
2020-09-04 10:05:56 +00:00
|
|
|
return p.replicas
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func (p *PlacementPolicy) SetReplicas(replicas []Replica) {
|
2020-09-04 10:05:56 +00:00
|
|
|
p.replicas = replicas
|
|
|
|
}
|
|
|
|
|
2021-11-17 13:58:38 +00:00
|
|
|
func (p *PlacementPolicy) GetSubnetID() *refs.SubnetID {
|
|
|
|
return p.subnetID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PlacementPolicy) SetSubnetID(id *refs.SubnetID) {
|
|
|
|
p.subnetID = id
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
func (a *Attribute) GetKey() string {
|
|
|
|
if a != nil {
|
|
|
|
return a.key
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Attribute) SetKey(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
a.key = v
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Attribute) GetValue() string {
|
|
|
|
if a != nil {
|
|
|
|
return a.value
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Attribute) SetValue(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
a.value = v
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
func (a *Attribute) GetParents() []string {
|
|
|
|
if a != nil {
|
|
|
|
return a.parents
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Attribute) SetParents(parent []string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
a.parents = parent
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 07:46:20 +00:00
|
|
|
func (ni *NodeInfo) GetPublicKey() []byte {
|
|
|
|
if ni != nil {
|
|
|
|
return ni.publicKey
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ni *NodeInfo) SetPublicKey(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
ni.publicKey = v
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 16:08:55 +00:00
|
|
|
// GetAddress returns node's network address.
|
|
|
|
//
|
|
|
|
// Deprecated: use IterateAddresses.
|
|
|
|
func (ni *NodeInfo) GetAddress() (addr string) {
|
|
|
|
ni.IterateAddresses(func(s string) bool {
|
|
|
|
addr = s
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAddress sets node's network address.
|
|
|
|
//
|
|
|
|
// Deprecated: use SetAddresses.
|
|
|
|
func (ni *NodeInfo) SetAddress(v string) {
|
|
|
|
ni.SetAddresses(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAddresses sets list of network addresses of the node.
|
|
|
|
func (ni *NodeInfo) SetAddresses(v ...string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
ni.addresses = v
|
2021-06-18 16:08:55 +00:00
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-06-18 16:08:55 +00:00
|
|
|
// NumberOfAddresses returns number of network addresses of the node.
|
|
|
|
func (ni *NodeInfo) NumberOfAddresses() int {
|
|
|
|
if ni != nil {
|
|
|
|
return len(ni.addresses)
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 16:08:55 +00:00
|
|
|
// IterateAddresses iterates over network addresses of the node.
|
|
|
|
// Breaks iteration on f's true return.
|
|
|
|
//
|
|
|
|
// Handler should not be nil.
|
|
|
|
func (ni *NodeInfo) IterateAddresses(f func(string) bool) {
|
2020-09-01 07:46:20 +00:00
|
|
|
if ni != nil {
|
2021-06-18 16:08:55 +00:00
|
|
|
for i := range ni.addresses {
|
|
|
|
if f(ni.addresses[i]) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 07:40:22 +00:00
|
|
|
func (ni *NodeInfo) GetAttributes() []Attribute {
|
2020-09-01 07:46:20 +00:00
|
|
|
if ni != nil {
|
|
|
|
return ni.attributes
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-02 07:40:22 +00:00
|
|
|
func (ni *NodeInfo) SetAttributes(v []Attribute) {
|
2022-03-23 11:42:57 +00:00
|
|
|
ni.attributes = v
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
func (ni *NodeInfo) GetState() NodeState {
|
|
|
|
if ni != nil {
|
|
|
|
return ni.state
|
|
|
|
}
|
|
|
|
|
|
|
|
return UnspecifiedState
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ni *NodeInfo) SetState(state NodeState) {
|
2022-03-23 11:42:57 +00:00
|
|
|
ni.state = state
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponseBody) GetVersion() *refs.Version {
|
|
|
|
if l != nil {
|
|
|
|
return l.version
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponseBody) SetVersion(version *refs.Version) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.version = version
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponseBody) GetNodeInfo() *NodeInfo {
|
|
|
|
if l != nil {
|
|
|
|
return l.nodeInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponseBody) SetNodeInfo(nodeInfo *NodeInfo) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.nodeInfo = nodeInfo
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoRequest) GetBody() *LocalNodeInfoRequestBody {
|
|
|
|
if l != nil {
|
|
|
|
return l.body
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoRequest) SetBody(body *LocalNodeInfoRequestBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.body = body
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponse) GetBody() *LocalNodeInfoResponseBody {
|
|
|
|
if l != nil {
|
|
|
|
return l.body
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponse) SetBody(body *LocalNodeInfoResponseBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.body = body
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 08:10:20 +00:00
|
|
|
// NetworkParameter represents NeoFS network parameter.
|
|
|
|
type NetworkParameter struct {
|
|
|
|
k, v []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetKey returns parameter key.
|
|
|
|
func (x *NetworkParameter) GetKey() []byte {
|
|
|
|
if x != nil {
|
|
|
|
return x.k
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetKey sets parameter key.
|
|
|
|
func (x *NetworkParameter) SetKey(k []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.k = k
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetValue returns parameter value.
|
|
|
|
func (x *NetworkParameter) GetValue() []byte {
|
|
|
|
if x != nil {
|
|
|
|
return x.v
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetValue sets parameter value.
|
|
|
|
func (x *NetworkParameter) SetValue(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.v = v
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkConfig represents NeoFS network configuration.
|
|
|
|
type NetworkConfig struct {
|
2022-03-01 13:41:42 +00:00
|
|
|
ps []NetworkParameter
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NumberOfParameters returns number of network parameters.
|
|
|
|
func (x *NetworkConfig) NumberOfParameters() int {
|
|
|
|
if x != nil {
|
|
|
|
return len(x.ps)
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// IterateParameters iterates over network parameters.
|
|
|
|
// Breaks iteration on f's true return.
|
|
|
|
//
|
|
|
|
// Handler must not be nil.
|
|
|
|
func (x *NetworkConfig) IterateParameters(f func(*NetworkParameter) bool) {
|
|
|
|
if x != nil {
|
|
|
|
for i := range x.ps {
|
2022-03-01 13:41:42 +00:00
|
|
|
if f(&x.ps[i]) {
|
2021-09-28 08:10:20 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetParameters sets list of network parameters.
|
2022-03-01 13:41:42 +00:00
|
|
|
func (x *NetworkConfig) SetParameters(v ...NetworkParameter) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.ps = v
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 16:36:03 +00:00
|
|
|
// NetworkInfo groups information about
|
|
|
|
// NeoFS network.
|
|
|
|
type NetworkInfo struct {
|
|
|
|
curEpoch, magicNum uint64
|
2021-09-28 08:10:20 +00:00
|
|
|
|
|
|
|
msPerBlock int64
|
|
|
|
|
|
|
|
netCfg *NetworkConfig
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetCurrentEpoch returns number of the current epoch.
|
|
|
|
func (i *NetworkInfo) GetCurrentEpoch() uint64 {
|
|
|
|
if i != nil {
|
|
|
|
return i.curEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCurrentEpoch sets number of the current epoch.
|
|
|
|
func (i *NetworkInfo) SetCurrentEpoch(epoch uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
i.curEpoch = epoch
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMagicNumber returns magic number of the sidechain.
|
|
|
|
func (i *NetworkInfo) GetMagicNumber() uint64 {
|
|
|
|
if i != nil {
|
|
|
|
return i.magicNum
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMagicNumber sets magic number of the sidechain.
|
|
|
|
func (i *NetworkInfo) SetMagicNumber(magic uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
i.magicNum = magic
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 08:10:20 +00:00
|
|
|
// GetMsPerBlock returns MillisecondsPerBlock network parameter.
|
|
|
|
func (i *NetworkInfo) GetMsPerBlock() int64 {
|
|
|
|
if i != nil {
|
|
|
|
return i.msPerBlock
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMsPerBlock sets MillisecondsPerBlock network parameter.
|
|
|
|
func (i *NetworkInfo) SetMsPerBlock(v int64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
i.msPerBlock = v
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetNetworkConfig returns NeoFS network configuration.
|
|
|
|
func (i *NetworkInfo) GetNetworkConfig() *NetworkConfig {
|
|
|
|
if i != nil {
|
|
|
|
return i.netCfg
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetworkConfig sets NeoFS network configuration.
|
|
|
|
func (i *NetworkInfo) SetNetworkConfig(v *NetworkConfig) {
|
2022-03-23 11:42:57 +00:00
|
|
|
i.netCfg = v
|
2021-09-28 08:10:20 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 16:36:03 +00:00
|
|
|
// NetworkInfoRequestBody is a structure of NetworkInfo request body.
|
|
|
|
type NetworkInfoRequestBody struct{}
|
|
|
|
|
|
|
|
// NetworkInfoResponseBody is a structure of NetworkInfo response body.
|
|
|
|
type NetworkInfoResponseBody struct {
|
|
|
|
netInfo *NetworkInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetNetworkInfo returns information about the NeoFS network.
|
|
|
|
func (i *NetworkInfoResponseBody) GetNetworkInfo() *NetworkInfo {
|
|
|
|
if i != nil {
|
|
|
|
return i.netInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetworkInfo sets information about the NeoFS network.
|
|
|
|
func (i *NetworkInfoResponseBody) SetNetworkInfo(netInfo *NetworkInfo) {
|
2022-03-23 11:42:57 +00:00
|
|
|
i.netInfo = netInfo
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *NetworkInfoRequest) GetBody() *NetworkInfoRequestBody {
|
|
|
|
if l != nil {
|
|
|
|
return l.body
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *NetworkInfoRequest) SetBody(body *NetworkInfoRequestBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.body = body
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *NetworkInfoResponse) GetBody() *NetworkInfoResponseBody {
|
|
|
|
if l != nil {
|
|
|
|
return l.body
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *NetworkInfoResponse) SetBody(body *NetworkInfoResponseBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.body = body
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
2022-09-17 09:59:54 +00:00
|
|
|
|
|
|
|
// NetMap represents structure of NeoFS network map.
|
|
|
|
type NetMap struct {
|
|
|
|
epoch uint64
|
|
|
|
|
|
|
|
nodes []NodeInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
// Epoch returns revision number of the NetMap.
|
|
|
|
func (x *NetMap) Epoch() uint64 {
|
|
|
|
if x != nil {
|
|
|
|
return x.epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetEpoch sets revision number of the NetMap.
|
|
|
|
func (x *NetMap) SetEpoch(v uint64) {
|
|
|
|
x.epoch = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nodes returns nodes presented in the NetMap.
|
|
|
|
func (x *NetMap) Nodes() []NodeInfo {
|
|
|
|
if x != nil {
|
|
|
|
return x.nodes
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNodes sets nodes presented in the NetMap.
|
|
|
|
func (x *NetMap) SetNodes(v []NodeInfo) {
|
|
|
|
x.nodes = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// SnapshotRequestBody represents structure of Snapshot request body.
|
|
|
|
type SnapshotRequestBody struct{}
|
|
|
|
|
|
|
|
// SnapshotRequest represents structure of Snapshot request.
|
|
|
|
type SnapshotRequest struct {
|
|
|
|
body *SnapshotRequestBody
|
|
|
|
|
|
|
|
session.RequestHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequest) GetBody() *SnapshotRequestBody {
|
|
|
|
if x != nil {
|
|
|
|
return x.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequest) SetBody(body *SnapshotRequestBody) {
|
|
|
|
x.body = body
|
|
|
|
}
|
|
|
|
|
|
|
|
// SnapshotResponseBody represents structure of Snapshot response body.
|
|
|
|
type SnapshotResponseBody struct {
|
|
|
|
netMap *NetMap
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetMap returns current NetMap.
|
|
|
|
func (x *SnapshotResponseBody) NetMap() *NetMap {
|
|
|
|
if x != nil {
|
|
|
|
return x.netMap
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetMap sets current NetMap.
|
|
|
|
func (x *SnapshotResponseBody) SetNetMap(netMap *NetMap) {
|
|
|
|
x.netMap = netMap
|
|
|
|
}
|
|
|
|
|
|
|
|
// SnapshotResponse represents structure of Snapshot response.
|
|
|
|
type SnapshotResponse struct {
|
|
|
|
body *SnapshotResponseBody
|
|
|
|
|
|
|
|
session.ResponseHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponse) GetBody() *SnapshotResponseBody {
|
|
|
|
if x != nil {
|
|
|
|
return x.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponse) SetBody(body *SnapshotResponseBody) {
|
|
|
|
x.body = body
|
|
|
|
}
|