netmap

package
v0.22.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilClient = errors.New("netmap contract client is nil")

ErrNilClient is returned by functions that expect a non-nil Client pointer, but received nil.

Functions

func IntegerAssert added in v0.12.0

func IntegerAssert(item stackitem.Item) (interface{}, error)

func StringAssert added in v0.19.0

func StringAssert(item stackitem.Item) (interface{}, error)

Types

type AddPeerArgs

type AddPeerArgs struct {
	// contains filtered or unexported fields
}

AddPeerArgs groups the arguments of add peer invocation call.

func (*AddPeerArgs) SetInfo

func (a *AddPeerArgs) SetInfo(v []byte)

SetInfo sets the peer information.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a wrapper over StaticClient which makes calls with the names and arguments of the NeoFS Netmap contract.

Working client must be created via constructor New. Using the Client that has been created with new(Client) expression (or just declaring a Client variable) is unsafe and can lead to panic.

func New

func New(c *client.StaticClient, opts ...Option) (*Client, error)

New creates, initializes and returns the Client instance.

If StaticClient is nil, client.ErrNilStaticClient is returned.

Other values are set according to provided options, or by default:

  • add peer method name: AddPeer;
  • new epoch method name: NewEpoch;
  • get network map method name: Netmap;
  • update state method name: UpdateState;

If desired option satisfies the default value, it can be omitted. If multiple options of the same config value are supplied, the option with the highest index in the arguments will be used.

func (*Client) AddPeer

func (c *Client) AddPeer(args AddPeerArgs) error

AddPeer invokes the call of add peer method of NeoFS Netmap contract.

func (*Client) Candidates added in v0.22.1

func (*Client) Config added in v0.12.0

func (c *Client) Config(args ConfigArgs, assert func(stackitem.Item) (interface{}, error)) (*ConfigValues, error)

Config performs the test invoke of get config value method of NeoFS Netmap contract.

func (*Client) Epoch added in v0.12.0

func (c *Client) Epoch(_ EpochArgs) (*EpochValues, error)

Epoch performs the test invoke of get epoch number method of NeoFS Netmap contract.

func (*Client) EpochSnapshot added in v0.14.1

func (c *Client) EpochSnapshot(args EpochSnapshotArgs) (*EpochSnapshotValues, error)

EpochSnapshot performs the test invoke of get snapshot of network map by epoch from NeoFS Netmap contract.

func (*Client) NetMap

func (c *Client) NetMap(_ GetNetMapArgs) (*GetNetMapValues, error)

NetMap performs the test invoke of get network map method of NeoFS Netmap contract.

func (*Client) NewEpoch

func (c *Client) NewEpoch(args NewEpochArgs) error

NewEpoch invokes the call of new epoch method of NeoFS Netmap contract.

func (*Client) SetConfig added in v0.22.0

func (c *Client) SetConfig(id, key []byte, value interface{}) error

SetConfig invokes `setConfig` method of NeoFS Netmap contract.

func (*Client) SetInnerRing added in v0.22.0

func (c *Client) SetInnerRing(keys keys.PublicKeys) error

SetInnerRing updates inner ring members in netmap contract.

func (*Client) Snapshot added in v0.12.0

func (c *Client) Snapshot(a GetSnapshotArgs) (*GetNetMapValues, error)

Snapshot performs the test invoke of get snapshot of network map from NeoFS Netmap contract. Contract saves only one previous epoch, so all invokes with diff > 1 return error.

func (*Client) UpdateState

func (c *Client) UpdateState(args UpdateStateArgs) error

UpdateState invokes the call of update state method of NeoFS Netmap contract.

type ConfigArgs added in v0.12.0

type ConfigArgs struct {
	// contains filtered or unexported fields
}

ConfigArgs groups the arguments of get config value test invoke call.

func (*ConfigArgs) SetKey added in v0.12.0

func (c *ConfigArgs) SetKey(v []byte)

SetKey sets binary key to configuration parameter.

type ConfigValues added in v0.12.0

type ConfigValues struct {
	// contains filtered or unexported fields
}

ConfigValues groups the stack parameters returned by get config test invoke.

func (ConfigValues) Value added in v0.12.0

func (c ConfigValues) Value() interface{}

Value returns configuration value.

type EpochArgs added in v0.12.0

type EpochArgs struct {
}

EpochArgs groups the arguments of get epoch number test invoke call.

type EpochSnapshotArgs added in v0.14.1

type EpochSnapshotArgs struct {
	// contains filtered or unexported fields
}

EpochSnapshotArgs groups the arguments of snapshot by epoch test invoke call.

func (*EpochSnapshotArgs) SetEpoch added in v0.14.1

func (a *EpochSnapshotArgs) SetEpoch(d uint64)

SetEpoch sets epoch number to get snapshot.

type EpochSnapshotValues added in v0.14.1

type EpochSnapshotValues struct {
	*GetNetMapValues
}

EpochSnapshotValues groups the stack parameters returned by snapshot by epoch test invoke.

type EpochValues added in v0.12.0

type EpochValues struct {
	// contains filtered or unexported fields
}

EpochValues groups the stack parameters returned by get epoch number test invoke.

func (EpochValues) Number added in v0.12.0

func (e EpochValues) Number() int64

Number return the number of NeoFS epoch.

type GetNetMapArgs

type GetNetMapArgs struct {
}

GetNetMapArgs groups the arguments of get network map test invoke call.

type GetNetMapCandidatesArgs added in v0.22.1

type GetNetMapCandidatesArgs struct {
}

GetNetMapCandidatesArgs groups the arguments of get network map candidates test invoke call.

type GetNetMapCandidatesValues added in v0.22.1

type GetNetMapCandidatesValues struct {
	// contains filtered or unexported fields
}

GetNetMapCandidatesValues groups the stack parameters returned by get network map candidates test invoke.

func (GetNetMapCandidatesValues) NetmapNodes added in v0.22.1

func (g GetNetMapCandidatesValues) NetmapNodes() []*PeerWithState

type GetNetMapValues

type GetNetMapValues struct {
	// contains filtered or unexported fields
}

GetNetMapValues groups the stack parameters returned by get network map test invoke.

func (GetNetMapValues) Peers

func (g GetNetMapValues) Peers() [][]byte

Peers return the list of peers from network map in a binary format.

type GetSnapshotArgs added in v0.12.0

type GetSnapshotArgs struct {
	// contains filtered or unexported fields
}

GetSnapshotArgs groups the arguments of get netmap snapshot test invoke call.

func (*GetSnapshotArgs) SetDiff added in v0.12.0

func (g *GetSnapshotArgs) SetDiff(d uint64)

SetDiff sets argument for snapshot method of netmap contract.

type NewEpochArgs

type NewEpochArgs struct {
	// contains filtered or unexported fields
}

NewEpochArgs groups the arguments of new epoch invocation call.

func (*NewEpochArgs) SetEpochNumber

func (a *NewEpochArgs) SetEpochNumber(v int64)

SetEpochNumber sets the new epoch number.

type NodeInfo added in v0.12.0

type NodeInfo = netmap.NodeInfo

type Option

type Option func(*cfg)

Option is a client configuration change function.

func WithAddPeerMethod

func WithAddPeerMethod(n string) Option

WithAddPeerMethod returns a client constructor option that specifies the method name of adding peer operation.

Ignores empty value.

If option not provided, "AddPeer" is used.

func WithConfigMethod added in v0.12.0

func WithConfigMethod(n string) Option

WithConfigMethod returns a client constructor option that specifies the method name of config value receiving operation.

Ignores empty value.

If option not provided, "config" is used.

func WithEpochMethod added in v0.12.0

func WithEpochMethod(n string) Option

WithEpochMethod returns a client constructor option that specifies the method name of epoch number receiving operation.

Ignores empty value.

If option not provided, "epoch" is used.

func WithEpochSnapshotMethod added in v0.14.1

func WithEpochSnapshotMethod(n string) Option

WithEpochSnapshotMethod returns a client constructor option that specifies the method name of snapshot by value receiving operation.

Ignores empty value.

If option not provided, "snapshotByValue" is used.

func WithNetMapMethod

func WithNetMapMethod(n string) Option

WithNetMapMethod returns a client constructor option that specifies the method name of network map receiving operation.

Ignores empty value.

If option not provided, "Netmap" is used.

func WithNewEpochMethod

func WithNewEpochMethod(n string) Option

WithNewEpochMethod returns a client constructor option that specifies the method name of new epoch operation.

Ignores empty value.

If option not provided, "NewEpoch" is used.

func WithUpdateStateMethod

func WithUpdateStateMethod(n string) Option

WithUpdateStateMethod returns a client constructor option that specifies the method name of peer state updating operation.

Ignores empty value.

If option not provided, "UpdateState" is used.

type PeerWithState added in v0.22.1

type PeerWithState struct {
	// contains filtered or unexported fields
}

PeerWithState groups information about peer and its state in network map.

func (PeerWithState) Peer added in v0.22.1

func (ps PeerWithState) Peer() []byte

func (PeerWithState) State added in v0.22.1

func (ps PeerWithState) State() State

type State added in v0.22.1

type State int64

State is an enumeration of various states of the NeoFS node.

const (
	// Undefined is unknown state.
	Undefined State = iota

	// Online is network unavailable state.
	Online

	// Offline is an active state in the network.
	Offline
)

type UpdateStateArgs

type UpdateStateArgs struct {
	// contains filtered or unexported fields
}

UpdateStateArgs groups the arguments of update state invocation call.

func (*UpdateStateArgs) SetPublicKey

func (u *UpdateStateArgs) SetPublicKey(v []byte)

SetPublicKey sets peer public key in a binary format.

func (*UpdateStateArgs) SetState

func (u *UpdateStateArgs) SetState(v int64)

SetState sets the new peer state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL