container

package
v0.13.1 Latest Latest
Warning

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

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

Documentation

Overview

Container contract is a contract deployed in NeoFS side chain.

Container contract stores and manages containers, extended ACLs and container size estimations. Contract does not perform sanity or signature checks of the containers or extended ACLs, it is done by Alphabet nodes of the Inner Ring. Alphabet nodes approve it by invoking the same Put or SetEACL methods with the same arguments.

Contract notifications

containerPut notification. This notification is produced when user wants to create new container. Alphabet nodes of the Inner Ring catch notification and validate container data, signature and token if it is present.

containerPut:
  - name: container
    type: ByteArray
  - name: signature
    type: Signature
  - name: publicKey
    type: PublicKey
  - name: token
    type: ByteArray

containerDelete notification. This notification is produced when container owner wants to delete container. Alphabet nodes of the Inner Ring catch notification and validate container ownership, signature and token if it is present.

containerDelete:
  - name: containerID
    type: ByteArray
  - name: signature
    type: Signature
  - name: token
    type: ByteArray

setEACL notification. This notification is produced when container owner wants to update extended ACL of the container. Alphabet nodes of the Inner Ring catch notification and validate container ownership, signature and token if it is present.

setEACL:
  - name: eACL
    type: ByteArray
  - name: signature
    type: Signature
  - name: publicKey
    type: PublicKey
  - name: token
    type: ByteArray

StartEstimation notification. This notification is produced when Storage nodes should exchange estimation values of container sizes among other Storage nodes.

StartEstimation:
  - name: epoch
    type: Integer

StopEstimation notification. This notification is produced when Storage nodes should calculate average container size based on received estimations and store it in Container contract.

StopEstimation:
  - name: epoch
    type: Integer

Index

Constants

View Source
const (

	// RegistrationFeeKey is a key in netmap config which contains fee for container registration.
	RegistrationFeeKey = "ContainerFee"
	// AliasFeeKey is a key in netmap config which contains fee for nice-name registration.
	AliasFeeKey = "ContainerAliasFee"

	// NotFoundError is returned if container is missing.
	NotFoundError = "container does not exist"
)

Variables

This section is empty.

Functions

func Delete

func Delete(containerID []byte, signature interop.Signature, token []byte)

Delete method removes container from contract storage if it was invoked by Alphabet nodes of the Inner Ring. Otherwise it produces containerDelete notification.

Signature is a RFC6979 signature of container ID. Token is optional and should be stable marshaled SessionToken structure from API.

If a container doesn't exist it panics with NotFoundError.

func GetContainerSize added in v0.4.0

func GetContainerSize(id []byte) containerSizes

GetContainerSize method returns container ID and slice of container estimations. Container estimation includes public key of the Storage Node that registered estimation and value of estimation.

Use ID obtained from ListContainerSizes method. Estimations are removed from contract storage every epoch, see NewEpoch method, therefore method can return different results in different epochs.

func List

func List(owner []byte) [][]byte

List method returns list of all container IDs owned by specified owner.

func ListContainerSizes added in v0.4.0

func ListContainerSizes(epoch int) [][]byte

ListContainerSizes method returns IDs of container size estimations that has been registered for specified epoch.

func NewEpoch added in v0.5.0

func NewEpoch(epochNum int)

NewEpoch method removes all container size estimations from epoch older than epochNum + 3. Can be invoked only by NewEpoch method of the Netmap contract.

func OnNEP11Payment added in v0.12.0

func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{})

OnNEP11Payment is needed for registration with contract as owner to work.

func Owner

func Owner(containerID []byte) []byte

Owner method returns 25 byte Owner ID of the container.

If a container doesn't exist it panics with NotFoundError.

func Put

func Put(container []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte)

Put method creates new container if it was invoked by Alphabet nodes of the Inner Ring. Otherwise it produces containerPut notification.

Container should be stable marshaled Container structure from API. Signature is a RFC6979 signature of Container. PublicKey contains public key of the signer. Token is optional and should be stable marshaled SessionToken structure from API.

func PutContainerSize added in v0.4.0

func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.PublicKey)

PutContainerSize method saves container size estimation in contract memory. Can be invoked only by Storage nodes from the network map. Method checks witness based on the provided public key of the Storage node.

If a container doesn't exist it panics with NotFoundError.

func PutNamed added in v0.12.0

func PutNamed(container []byte, signature interop.Signature,
	publicKey interop.PublicKey, token []byte,
	name, zone string)

PutNamed is similar to put but also sets a TXT record in nns contract. Note that zone must exist.

func SetEACL

func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte)

SetEACL method sets new extended ACL table related to the contract if it was invoked by Alphabet nodes of the Inner Ring. Otherwise it produces setEACL notification.

EACL should be stable marshaled EACLTable structure from API. Signature is a RFC6979 signature of Container. PublicKey contains public key of the signer. Token is optional and should be stable marshaled SessionToken structure from API.

If a container doesn't exist it panics with NotFoundError.

func StartContainerEstimation added in v0.4.0

func StartContainerEstimation(epoch int)

StartContainerEstimation method produces StartEstimation notification. Can be invoked only by Alphabet nodes of the Inner Ring.

func StopContainerEstimation added in v0.4.0

func StopContainerEstimation(epoch int)

StopContainerEstimation method produces StopEstimation notification. Can be invoked only by Alphabet nodes of the Inner Ring.

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 Version

func Version() int

Version returns version of the contract.

Types

type Container added in v0.9.0

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

func Get

func Get(containerID []byte) Container

Get method returns structure that contains stable marshaled Container structure, signature, public key of the container creator and stable marshaled SessionToken structure if it was provided.

If a container doesn't exist it panics with NotFoundError.

type ExtendedACL added in v0.9.0

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

func EACL

func EACL(containerID []byte) ExtendedACL

EACL method returns structure that contains stable marshaled EACLTable structure, signature, public key of the extended ACL setter and stable marshaled SessionToken structure if it was provided.

If a container doesn't exist it panics with NotFoundError.

Jump to

Keyboard shortcuts

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