storagegroup

package
v1.0.0-rc.12 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package storagegroup provides features to work with information that is used for proof of storage in NeoFS system.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFromObject

func ReadFromObject(sg *StorageGroup, o objectSDK.Object) error

ReadFromObject assemble StorageGroup from a regular Object structure. Object must contain unambiguous information about its expiration epoch, otherwise behaviour is undefined.

Returns any error appeared during storage group parsing; returns error if object is not of TypeStorageGroup type.

func WriteToObject

func WriteToObject(sg StorageGroup, o *objectSDK.Object)

WriteToObject writes StorageGroup to a regular Object structure. Object must not contain ambiguous information about its expiration epoch or must not have it at all.

Written information:

  • expiration epoch;
  • object type (TypeStorageGroup);
  • raw payload.

Types

type StorageGroup

type StorageGroup storagegroup.StorageGroup

StorageGroup represents storage group of the NeoFS objects.

StorageGroup is mutually compatible with github.com/nspcc-dev/neofs-api-go/v2/storagegroup.StorageGroup message. See ReadFromMessageV2 / WriteToMessageV2 methods.

Instances can be created using built-in var declaration.

Note that direct typecast is not safe and may result in loss of compatibility:

_ = StorageGroup(storagegroup.StorageGroup) // not recommended
Example (Marshalling)

Instances can be also used to process NeoFS API V2 protocol messages with [https://github.com/nspcc-dev/neofs-api] package.

package main

import (
	apiGoStoragegroup "github.com/nspcc-dev/neofs-api-go/v2/storagegroup"
	"github.com/nspcc-dev/neofs-sdk-go/storagegroup"
)

func main() {
	// import apiGoStoragegroup "github.com/nspcc-dev/neofs-api-go/v2/storagegroup"

	// On the client side.

	var sg storagegroup.StorageGroup
	var msg apiGoStoragegroup.StorageGroup
	sg.WriteToV2(&msg)
	// *send message*

	// On the server side.

	_ = sg.ReadFromV2(msg)
}
Output:

Example (Validation)

StorageGroup type groups verification values for Data Audit sessions.

package main

import (
	"github.com/nspcc-dev/neofs-sdk-go/storagegroup"
)

func main() {
	// receive sg info

	var sg storagegroup.StorageGroup

	sg.ExpirationEpoch()    // expiration of the storage group
	sg.Members()            // objects in the group
	sg.ValidationDataHash() // hash for objects validation
	sg.ValidationDataSize() // total objects' payload size
}
Output:

func (StorageGroup) ExpirationEpoch

func (sg StorageGroup) ExpirationEpoch() uint64

ExpirationEpoch returns last NeoFS epoch number of the storage group lifetime.

Zero StorageGroup has 0 expiration epoch.

See also SetExpirationEpoch.

func (StorageGroup) Marshal

func (sg StorageGroup) Marshal() ([]byte, error)

Marshal marshals StorageGroup into a protobuf binary form.

See also Unmarshal.

func (StorageGroup) MarshalJSON

func (sg StorageGroup) MarshalJSON() ([]byte, error)

MarshalJSON encodes StorageGroup to protobuf JSON format.

See also UnmarshalJSON.

func (StorageGroup) Members

func (sg StorageGroup) Members() []oid.ID

Members returns strictly ordered list of storage group member objects.

Zero StorageGroup has nil members value.

See also SetMembers.

func (*StorageGroup) ReadFromV2

func (sg *StorageGroup) ReadFromV2(m storagegroup.StorageGroup) error

ReadFromV2 reads StorageGroup from the storagegroup.StorageGroup message. Checks if the message conforms to NeoFS API V2 protocol.

See also WriteToV2.

func (*StorageGroup) SetExpirationEpoch

func (sg *StorageGroup) SetExpirationEpoch(epoch uint64)

SetExpirationEpoch sets last NeoFS epoch number of the storage group lifetime.

See also ExpirationEpoch.

func (*StorageGroup) SetMembers

func (sg *StorageGroup) SetMembers(members []oid.ID)

SetMembers sets strictly ordered list of storage group member objects.

See also Members.

func (*StorageGroup) SetValidationDataHash

func (sg *StorageGroup) SetValidationDataHash(hash checksum.Checksum)

SetValidationDataHash sets homomorphic hash from the concatenation of the payloads of the storage group members.

See also ValidationDataHash.

func (*StorageGroup) SetValidationDataSize

func (sg *StorageGroup) SetValidationDataSize(epoch uint64)

SetValidationDataSize sets total size of the payloads of objects in the storage group.

See also ValidationDataSize.

func (*StorageGroup) Unmarshal

func (sg *StorageGroup) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of StorageGroup.

See also Marshal.

func (*StorageGroup) UnmarshalJSON

func (sg *StorageGroup) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes StorageGroup from protobuf JSON format.

See also MarshalJSON.

func (StorageGroup) ValidationDataHash

func (sg StorageGroup) ValidationDataHash() (v checksum.Checksum, isSet bool)

ValidationDataHash returns homomorphic hash from the concatenation of the payloads of the storage group members and bool that indicates checksum presence in the storage group.

Zero StorageGroup does not have validation data checksum.

See also SetValidationDataHash.

func (StorageGroup) ValidationDataSize

func (sg StorageGroup) ValidationDataSize() uint64

ValidationDataSize returns total size of the payloads of objects in the storage group.

Zero StorageGroup has 0 data size.

See also SetValidationDataSize.

func (StorageGroup) WriteToV2

func (sg StorageGroup) WriteToV2(m *storagegroup.StorageGroup)

WriteToV2 writes StorageGroup to the storagegroup.StorageGroup message. The message must not be nil.

See also ReadFromV2.

Directories

Path Synopsis
Package storagegrouptest provides functions for convenient testing of storagegroup package API.
Package storagegrouptest provides functions for convenient testing of storagegroup package API.

Jump to

Keyboard shortcuts

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