Documentation
¶
Overview ¶
Package container implements Container contract which is deployed to FS chain.
Container contract stores and manages containers, extended ACLs and container size estimations. Contract does not perform sanity or signature checks of 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 a user wants to create a new container. Alphabet nodes of the Inner Ring catch the notification and validate container data, signature and token if 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 a container owner wants to delete a container. Alphabet nodes of the Inner Ring catch the notification and validate container ownership, signature and token if present.
containerDelete:
- name: containerID
type: ByteArray
- name: signature
type: Signature
- name: token
type: ByteArray
nodesUpdate notification. This notification is produced when a container roster is changed. Triggered only by the Alphabet at the beginning of epoch.
name: NodesUpdate
- name: ContainerID
type: hash256
setEACL notification. This notification is produced when a container owner wants to update an extended ACL of a container. Alphabet nodes of the Inner Ring catch the notification and validate container ownership, signature and token if 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 ¶
- func AddNextEpochNodes(cID interop.Hash256, placementVector uint8, publicKeys []interop.PublicKey)
- func Alias(cid []byte) string
- func CommitContainerListUpdate(cID interop.Hash256, replicas []uint8)
- func ContainersOf(owner []byte) iterator.Iterator
- func Count() int
- func Delete(containerID []byte, signature interop.Signature, token []byte)
- func IterateAllContainerSizes(epoch int) iterator.Iterator
- func IterateContainerSizes(epoch int, cid interop.Hash256) iterator.Iterator
- func List(owner []byte) [][]byte
- func ListContainerSizes(epoch int) [][]bytedeprecated
- func NewEpoch(epochNum int)
- func Nodes(cID interop.Hash256, placementVector uint8) iterator.Iterator
- func OnNEP11Payment(a interop.Hash160, b int, c []byte, d any)
- func Owner(containerID []byte) []byte
- func Put(container []byte, signature interop.Signature, publicKey interop.PublicKey, ...)
- func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.PublicKey)
- func PutMeta(container []byte, signature interop.Signature, publicKey interop.PublicKey, ...)
- func PutNamed(container []byte, signature interop.Signature, publicKey interop.PublicKey, ...)
- func PutNamedOverloaded(container []byte, signature interop.Signature, publicKey interop.PublicKey, ...)
- func ReplicasNumbers(cID interop.Hash256) iterator.Iterator
- func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, ...)
- func StartContainerEstimation(epoch int)
- func StopContainerEstimation(epoch int)
- func SubmitObjectPut(metaInformation []byte, sigs [][]interop.Signature)
- func Update(script []byte, manifest []byte, data any)
- func VerifyPlacementSignatures(cid interop.Hash256, msg []byte, sigs [][]interop.Signature) bool
- func Version() int
- type Container
- type ContainerSizes
- type Estimation
- type ExtendedACL
- type StorageNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNextEpochNodes ¶
AddNextEpochNodes accumulates passed nodes as container members for the next epoch to be committed using CommitContainerListUpdate. Nodes must be grouped by selector index from placement policy (SELECT clauses). Results of the call operation can be received via Nodes. This method must be called only when a container list is changed, otherwise nothing should be done. Call must be signed by the Alphabet nodes.
func Alias ¶
Alias method returns a string with an alias of the container if it's set (Null otherwise).
If the container doesn't exist, it panics with NotFoundError.
func CommitContainerListUpdate ¶
CommitContainerListUpdate commits container list changes made by AddNextEpochNodes calls in advance. Replicas must correspond to ordered placement policy (REP clauses). If no AddNextEpochNodes have been made, it clears container list. Makes "ContainerUpdate" notification with container ID after successful list change. Call must be signed by the Alphabet nodes.
func ContainersOf ¶
ContainersOf iterates over all container IDs owned by the specified owner. If owner is nil, it iterates over all containers.
func Delete ¶
Delete method removes a container from the contract storage if it has been invoked by Alphabet nodes of the Inner Ring. Otherwise, it produces containerDelete notification.
Signature is a RFC6979 signature of the container ID. Token is optional and should be a stable marshaled SessionToken structure from API.
If the container doesn't exist, it panics with NotFoundError.
func IterateAllContainerSizes ¶
IterateAllContainerSizes method returns iterator over all container size estimations that have been registered for the specified epoch. Items returned from this iterator are key-value pairs with keys having container ID as a prefix and values being Estimation structures.
func IterateContainerSizes ¶
IterateContainerSizes method returns iterator over specific container size estimations that have been registered for the specified epoch. The iterator items are Estimation structures.
func ListContainerSizes
deprecated
ListContainerSizes method returns the IDs of container size estimations that have been registered for the specified epoch.
Deprecated: please use IterateAllContainerSizes API, this one is not convenient to use and limited in the number of items it can return. It will be removed in future versions.
func NewEpoch ¶
func NewEpoch(epochNum int)
NewEpoch method removes all container size estimations from epoch older than epochNum + 3. It can be invoked only by NewEpoch method of the Netmap contract.
func Nodes ¶
Nodes returns iterator over members of the container. The list is handled by the Alphabet nodes and must be updated via AddNextEpochNodes and CommitContainerListUpdate calls.
func OnNEP11Payment ¶
OnNEP11Payment is needed for registration with contract as the owner to work.
func Owner ¶
Owner method returns a 25 byte Owner ID of the container.
If the container doesn't exist, it panics with NotFoundError.
func Put ¶
Put method creates a new container if it has been invoked by Alphabet nodes of the Inner Ring. Otherwise, it produces containerPut notification.
Container should be a stable marshaled Container structure from API. Signature is a RFC6979 signature of the Container. PublicKey contains the public key of the signer. Token is optional and should be a stable marshaled SessionToken structure from API.
func PutContainerSize ¶
PutContainerSize method saves container size estimation in contract memory. It can be invoked only by Storage nodes from the network map. This method checks witness based on the provided public key of the Storage node.
If the container doesn't exist, it panics with NotFoundError.
func PutMeta ¶
func PutMeta(container []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte, name, zone string, metaOnChain bool)
PutMeta is the same as Put and PutNamed (and exposed as put from the contract via overload), but allows named containers and container's meta-information be handled and notified using the chain. If name and zone are non-empty strings, it behaves the same as PutNamed; empty strings make a regular Put call.
func PutNamed ¶
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. DEPRECATED: call Put with the same args instead.
func PutNamedOverloaded ¶
func PutNamedOverloaded(container []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte, name, zone string)
PutNamedOverloaded is the same as Put (and exposed as put from the contract via overload), but allows named container creation via NNS contract.
func ReplicasNumbers ¶
ReplicasNumbers returns iterator over saved by CommitContainerListUpdate container's replicas from placement policy.
func SetEACL ¶
SetEACL method sets a 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 a stable marshaled EACLTable structure from API. Protocol version and container reference must be set in 'version' and 'container_id' fields respectively. Signature is a RFC6979 signature of the Container. PublicKey contains the public key of the signer. Token is optional and should be a stable marshaled SessionToken structure from API.
If the container doesn't exist, it panics with NotFoundError.
func StartContainerEstimation ¶
func StartContainerEstimation(epoch int)
StartContainerEstimation method produces StartEstimation notification. It can be invoked only by Alphabet nodes of the Inner Ring.
func StopContainerEstimation ¶
func StopContainerEstimation(epoch int)
StopContainerEstimation method produces StopEstimation notification. It can be invoked only by Alphabet nodes of the Inner Ring.
func SubmitObjectPut ¶
SubmitObjectPut registers successful object PUT operation and notifies about it. metaInformation must be signed by container nodes according to container's placement, see VerifyPlacementSignatures. metaInformation must contain information about an object placed to a container that was created using Put (PutMeta) with enabled meta-on-chain option.
func Update ¶
Update method updates contract source code and manifest. It can be invoked by committee only.
func VerifyPlacementSignatures ¶
VerifyPlacementSignatures verifies that message has been signed by container members according to container's placement policy: there should be at least REP number of signatures for every placement vector. sigs must be container's number of SELECTs length.
Types ¶
type Container ¶
type ContainerSizes ¶
type ContainerSizes struct {
CID []byte
Estimations []Estimation
}
func GetContainerSize
deprecated
func GetContainerSize(id []byte) ContainerSizes
GetContainerSize method returns the container ID and a slice of container estimations. Container estimation includes the public key of the Storage Node that registered estimation and value of estimation.
Use the ID obtained from ListContainerSizes method. Estimations are removed from contract storage every epoch, see NewEpoch method; therefore, this method can return different results during different epochs.
Deprecated: please use IterateContainerSizes API, this one is not convenient to use and limited in the number of items it can return. It will be removed in future versions.
type Estimation ¶
Estimation contains the public key of the estimator (storage node) and the size this estimator has for the container.
type ExtendedACL ¶
func EACL ¶
func EACL(containerID []byte) ExtendedACL
EACL method returns a structure that contains a stable marshaled EACLTable structure, the signature, the public key of the extended ACL setter and a stable marshaled SessionToken structure if it was provided.
If the container doesn't exist, it panics with NotFoundError.
type StorageNode ¶
type StorageNode struct {
Info []byte
}