netmap

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Netmap contract is a contract deployed in NeoFS side chain.

Netmap contract stores and manages NeoFS network map, Storage node candidates and epoch number counter. In notary disabled environment, contract also stores list of Inner Ring node keys.

Contract notifications

AddPeer notification. This notification is produced when Storage node sends bootstrap request by invoking AddPeer method.

AddPeer
  - name: nodeInfo
    type: ByteArray

UpdateState notification. This notification is produced when Storage node wants to change it's state (go offline) by invoking UpdateState method. Supported states: (2) -- offline.

UpdateState
  - name: state
    type: Integer
  - name: publicKey
    type: PublicKey

NewEpoch notification. This notification is produced when new epoch is applied in the network by invoking NewEpoch method.

NewEpoch
  - name: epoch
    type: Integer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPeer

func AddPeer(nodeInfo []byte)

AddPeer method adds new candidate to the next network map if it was invoked by Alphabet node. If it was invoked by node candidate, it produces AddPeer notification. Otherwise method throws panic.

If the candidate already exists, it's info is updated. NodeInfo argument contains stable marshaled version of netmap.NodeInfo structure.

func Config

func Config(key []byte) interface{}

Config returns configuration value of NeoFS configuration. If key does not exists, returns nil.

func Epoch

func Epoch() int

Epoch method returns current epoch number.

func InnerRingList

func InnerRingList() []common.IRNode

InnerRingList method returns slice of structures that contains public key of Inner Ring node. Should be used only in notary disabled environment.

If notary enabled, then look to NeoFSAlphabet role in native RoleManagement contract of the side chain.

func LastEpochBlock added in v0.10.0

func LastEpochBlock() int

LastEpochBlock method returns block number when current epoch was applied.

func ListConfig

func ListConfig() []record

ListConfig returns array of structures that contain key and value of all NeoFS configuration records. Key and value are both byte arrays.

func Netmap

func Netmap() []storageNode

Netmap method returns list of structures that contain byte array of stable marshalled netmap.NodeInfo structure. These structure contain Storage nodes of current epoch.

func NetmapCandidates added in v0.9.0

func NetmapCandidates() []netmapNode

Snapshot method returns list of structures that contain node state and byte array of stable marshalled netmap.NodeInfo structure. These structure contain Storage node candidates for next epoch.

func NewEpoch

func NewEpoch(epochNum int)

NewEpoch method changes epoch number up to provided epochNum argument. Can be invoked only by Alphabet nodes. If provided epoch number is less or equal current epoch number, method throws panic.

When epoch number updated, contract sets storage node candidates as current network map. Also contract invokes NewEpoch method on Balance and Container contracts.

Produces NewEpoch notification.

func Register added in v0.13.0

func Register(nodeInfo []byte)

Register method tries to add new candidate to the network map by emitting AddPeer notification. Should be invoked by the registree.

func SetConfig

func SetConfig(id, key, val []byte)

SetConfig key-value pair as a NeoFS runtime configuration value. Can be invoked only by Alphabet nodes.

func Snapshot

func Snapshot(diff int) []storageNode

Snapshot method returns list of structures that contain node state (online: 1) and byte array of stable marshalled netmap.NodeInfo structure. These structure contain Storage nodes of specified epoch.

Netmap contract contains only two recent network map snapshot: current and previous epoch. For diff bigger than 1 or less than 0 method throws panic.

func SnapshotByEpoch added in v0.3.1

func SnapshotByEpoch(epoch int) []storageNode

SnapshotByEpoch method returns list of structures that contain node state (online: 1) and byte array of stable marshalled netmap.NodeInfo structure. These structure contain Storage nodes of specified epoch.

Netmap contract contains only two recent network map snapshot: current and previous epoch. For all others epoch method throws panic.

func Update added in v0.11.0

func Update(script []byte, manifest []byte, data interface{})

Update method updates contract source code and manifest. Can be invoked only by committee.

func UpdateInnerRing

func UpdateInnerRing(keys []interop.PublicKey)

UpdateInnerRing method updates list of Inner Ring node keys. Should be used only in notary disabled environment. Can be invoked only by Alphabet nodes.

If notary enabled, then update NeoFSAlphabet role in native RoleManagement contract of the side chain. Use notary service to collect multi signature.

func UpdateState

func UpdateState(state int, publicKey interop.PublicKey)

UpdateState method updates state of node from the network map candidate list if it was invoked by Alphabet node. If it was invoked by public key owner, then it produces UpdateState notification. Otherwise method throws panic.

State argument defines node state. The only supported state now is (2) -- offline state. Node is removed from network map candidate list.

Method panics when invoked with unsupported states.

func Version

func Version() int

Version returns version of the contract.

Types

This section is empty.

Jump to

Keyboard shortcuts

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