netmap

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 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

View Source
const (
	OnlineState nodeState
	OfflineState
)
View Source
const (

	// SnapshotCount contains the number of previous snapshots stored by this contract.
	// Must be less than 255.
	SnapshotCount = 10
)

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 AddPeerIR added in v0.15.0

func AddPeerIR(nodeInfo []byte)

AddPeerIR method tries to add new candidate to the network map. Should only be invoked in notary-enabled environment by the alphabet.

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

NetmapCandidates 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 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. For notary-ENABLED environment tx must be signed by both storage node and the alphabet. To force update without storage node signature, see `UpdateStateIR`.

For notary-DISABLED environment the behaviour depends on who signed the transaction: 1. If it was signed by alphabet, go into voting. 2. If it was signed by a storage node, emit `UpdateState` notification. 2. Fail in any other case.

The behaviour can be summarized in the following table: | notary \ Signer | Storage node | Alphabet | Both | | ENABLED | FAIL | FAIL | OK | | DISABLED | NOTIFICATION | OK | OK (same as alphabet) | 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 UpdateStateIR added in v0.15.0

func UpdateStateIR(state nodeState, publicKey interop.PublicKey)

UpdateStateIR method tries to change node state in the network map. Should only be invoked in notary-enabled environment by the alphabet.

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