storagegroup

package
v0.0.0-...-5e759bf Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 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 FrostFS system.

StorageGroup type groups verification values for Data Audit sessions:

// receive sg info

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

Instances can be also used to process FrostFS API V2 protocol messages (see neo.fs.v2.storagegroup package in https://github.com/TrueCloudLab/frostfs-api).

On client side:

import "github.com/TrueCloudLab/frostfs-api-go/v2/storagegroup"

var msg storagegroup.StorageGroup
sg.WriteToV2(&msg)

// send msg

On server side:

// recv msg

var sg StorageGroupDecimal
sg.ReadFromV2(msg)

// process sg

Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.

Index

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 FrostFS objects.

StorageGroup is mutually compatible with github.com/TrueCloudLab/frostfs-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

func (StorageGroup) ExpirationEpoch

func (sg StorageGroup) ExpirationEpoch() uint64

ExpirationEpoch returns last FrostFS 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 FrostFS API V2 protocol.

See also WriteToV2.

func (*StorageGroup) SetExpirationEpoch

func (sg *StorageGroup) SetExpirationEpoch(epoch uint64)

SetExpirationEpoch sets last FrostFS 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