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
ContainerQuotaSet notification. This notification is produced when container's owner sets (updates) size limitation for storage used for all objects in this container.
ContainerQuotaSet - name: ContainerID type: Hash256 - name: LimitValue type: Integer - name: Hard type: Boolean
UserQuotaSet notification. This notification is produced when container's owner sets (updates) size limitation for storage used for all objects in _all_ containers he owns.
UserQuotaSet - name: UserID type: ByteArray # 25 byte N3 address - name: LimitValue type: Integer - name: Hard type: Boolean
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 Create(cnr []byte, invocScript, verifScript, sessionToken []byte, name, zone string, ...)
- func Delete(containerID []byte, signature interop.Signature, token []byte)
- func GetContainerData(id []byte) []byte
- func GetEACLData(id []byte) []byte
- func GetTakenSpaceByUser(user []byte) int
- func IterateAllContainerSizes(epoch int) iterator.Iteratordeprecated
- func IterateAllReportSummaries() iterator.Iterator
- func IterateContainerSizes(epoch int, cid interop.Hash256) iterator.Iteratordeprecated
- func IterateReports(cid interop.Hash256) iterator.Iterator
- 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)deprecated
- func PutEACL(eACL []byte, invocScript, verifScript, sessionToken []byte)
- 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 PutReport(cid interop.Hash256, sizeBytes, objsNumber int, pubKey interop.PublicKey)
- func Remove(id []byte, invocScript, verifScript, sessionToken []byte)
- func ReplicasNumbers(cID interop.Hash256) iterator.Iterator
- func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, ...)
- func SetHardContainerQuota(cID interop.Hash256, size int)
- func SetHardUserQuota(user []byte, size int)
- func SetSoftContainerQuota(cID interop.Hash256, size int)
- func SetSoftUserQuota(user []byte, size int)
- func SubmitObjectPut(metaInformation []byte, sigs [][]interop.Signature)
- func Update(nefFile, 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 NodeReport
- type NodeReportSummary
- type Quota
- 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 Create ¶ added in v0.22.0
func Create(cnr []byte, invocScript, verifScript, sessionToken []byte, name, zone string, metaOnChain bool)
Create saves container descriptor serialized according to the NeoFS API binary protocol. Created containers are content-addressed: they may be accessed by SHA-256 checksum of their data. On success, Create throws 'Created' notification event.
Created containers are disposable: if they are deleted, they cannot be created again. Create throws cst.ErrorDeleted exception on recreation attempts.
Domain name is optional. If specified, it is used to register 'name.zone' domain for given container. Domain zone is optional: it defaults to the 6th contract deployment parameter which itself defaults to 'container'.
Meta-on-chain boolean flag specifies whether meta information about objects from this container can be collected for it.
The operation is paid. Container owner pays per-container fee (global chain configuration) to each committee member. If domain registration is requested, additional alias fee (also a configuration) is added to each payment.
Create must have chain's committee multi-signature witness. Invocation script, verification script and session token parameters are owner credentials. They are transmitted in notary transactions carrying original users' requests. IR verifies requests and approves them via multi-signature. Once creation is approved, container is persisted and becomes accessible. Credentials are disposable and do not persist in the chain.
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. Deprecated: use Remove instead.
func GetContainerData ¶ added in v0.22.0
GetContainerData returns binary of the container it was created with by ID.
If the container is missing, GetContainerData throws cst.NotFoundError exception.
func GetEACLData ¶ added in v0.22.0
GetEACLData returns binary of container eACL it was put with by the container ID.
If the container is missing, GetEACLData throws cst.NotFoundError exception.
func GetTakenSpaceByUser ¶ added in v0.24.0
GetTakenSpaceByUser returns total load space in all containers user owns. If user have no containers, it returns 0.
func IterateAllContainerSizes
deprecated
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.
Deprecated: method iterates nothing, use [IterateAllEstimations] instead.
func IterateAllReportSummaries ¶ added in v0.24.0
IterateAllReportSummaries method returns iterator over all total container sizes 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 NodeReportSummary structures.
func IterateContainerSizes
deprecated
IterateContainerSizes method returns iterator over specific container size estimations that have been registered for the specified epoch. The iterator items are Estimation structures.
Deprecated: method iterates nothing, use IterateReports instead.
func IterateReports ¶ added in v0.24.0
IterateReports method returns iterator over nodes' reports that were claimed for specified epoch and container.
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.
Deprecated: method always returns empty array. Use [IterateAllEstimations] instead.
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. Deprecated: use Create instead.
func PutContainerSize
deprecated
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.
Deprecated: method is no-op, use PutReport instead.
func PutEACL ¶ added in v0.22.0
PutEACL puts given eACL serialized according to the NeoFS API binary protocol for the container it is referenced to. Operation must be allowed in the container's basic ACL. If container does not exist, PutEACL throws cst.NotFoundError exception. On success, PutEACL throws 'EACLChanged' notification event.
See Create for details.
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. Deprecated: use Create instead.
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: use Create 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. Deprecated: use Create instead.
func PutReport ¶ added in v0.24.0
PutReport method saves container's state report in contract memory. It must be invoked only by Storage nodes that belong to reported container. This method checks witness based on the provided public key of the Storage node. sizeBytes is a total storage that is used by storage node for storing all marshaled objects that belong to the specified container. objsNumber is a total number of container's object storage node have.
If the container doesn't exist, it panics with cst.NotFoundError.
func Remove ¶ added in v0.22.0
Remove removes all data for the referenced container. Remove is no-op if container does not exist. On success, Remove throws 'Removed' notification event.
See Create for details.
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. Deprecated: use PutEACL instead.
func SetHardContainerQuota ¶ added in v0.24.0
SetHardContainerQuota sets hard size quota that limits all space used for storing objects in cID (including object replicas). Non-positive size sets no limitation. After exceeding the limit nodes will refuse any further PUTs. Call must be signed by cID's owner. Limit can be changed with a repeated call. See also SetSoftContainerQuota. Panics if cID is incorrect or container does not exist.
func SetHardUserQuota ¶ added in v0.24.0
SetHardUserQuota sets size quota that limits all space used for storing objects in all containers that belong to user (including object replicas). Non-positive size sets no limitation. After exceeding the limit nodes will refuse any further PUTs. Call must be signed by user. Limit can be changed with a repeated call. See also SetSoftUserQuota. Panics if user is incorrect.
func SetSoftContainerQuota ¶ added in v0.24.0
SetSoftContainerQuota sets soft size quota that limits all space used for storing objects in cID (including object replicas). Non-positive size sets no limitation. After exceeding the limit nodes are instructed to warn only, without denial of service. Call must be signed by cID's owner. Limit can be changed with a repeated call. See also SetHardContainerQuota. Panics if cID is incorrect or container does not exist.
func SetSoftUserQuota ¶ added in v0.24.0
SetSoftUserQuota sets size quota that limits all space used for storing objects in all containers that belong to user (including object replicas). Non-positive size sets no limitation. After exceeding the limit nodes are instructed to warn only, without denial of service. Call must be signed by user. Limit can be changed with a repeated call. See also SetHardUserQuota. Panics if user is incorrect.
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 ¶
func Get ¶
Get method returns a structure that contains a stable marshaled Container structure, the signature, the public key of the container creator and a stable marshaled SessionToken structure if it was provided.
If the container doesn't exist, it panics with NotFoundError. Deprecated: use GetContainerData instead.
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.
Deprecated: method always returns zero values, use GetNodeReportSummary or GetReportByNode instead.
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. Deprecated: use GetEACLData instead.
type NodeReport ¶ added in v0.24.0
type NodeReport struct {
PublicKey interop.PublicKey
ContainerSize int
NumberOfObjects int
NumberOfReports int
LastUpdateEpoch int
}
NodeReport is a report by a certain storage node about its storage engine's volume it uses for a certain container.
func GetReportByNode ¶ added in v0.24.0
func GetReportByNode(cid interop.Hash256, pubKey interop.PublicKey) NodeReport
GetReportByNode method returns the latest report, that node with pubKey reported for the specified container via PutReport.
If the container doesn't exist, it panics with cst.NotFoundError. If no reports were claimed, it returns zero values.
type NodeReportSummary ¶ added in v0.24.0
NodeReportSummary is the summary of all NodeReport claimed by all storage nodes.
func GetNodeReportSummary ¶ added in v0.24.0
func GetNodeReportSummary(cid interop.Hash256) NodeReportSummary
GetNodeReportSummary method returns a sum of object count and occupied volume as reported by storage nodes provided via PutReport.
If the container doesn't exist, it panics with cst.NotFoundError. If no reports were claimed, it returns zero values.
type Quota ¶ added in v0.24.0
Quota describes size limitation for a container or for a user as a sum of all objects in all his containers.
func ContainerQuota ¶ added in v0.24.0
ContainerQuota returns container size quota set by cID's owner. If no limitation has been set, returns empty values (both limitations are set to 0). Non-positive limitation must be treated as no limits. Panics if cID is incorrect or container does not exist.
type StorageNode ¶
type StorageNode struct {
Info []byte
}