ec

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatDataParts

func ConcatDataParts(rule Rule, dataLen uint64, parts [][]byte) []byte

ConcatDataParts returns a new slice of dataLen bytes originating given EC parts according to rule.

Panics if there are less than Rule.DataPartNum parts.

func Decode

func Decode(rule Rule, dataLen uint64, parts [][]byte) ([]byte, error)

Decode decodes source data of known len from EC parts obtained by applying specified rule.

func DecodeIndexes added in v0.50.0

func DecodeIndexes(rule Rule, parts [][]byte, idxs []int) error

DecodeIndexes decodes specified EC parts obtained by applying specified rule.

func DecodeRange added in v0.50.0

func DecodeRange(rule Rule, fromIdx, toIdx int, parts [][]byte) error

DecodeRange decodes specified range of EC parts obtained by applying specified rule. If no error, parts[from:to+1] contains recovered data.

func Encode

func Encode(rule Rule, data []byte) ([][]byte, []string, error)

Encode encodes given data according to specified EC rule and returns coded parts. First Rule.DataPartNum elements are data parts, other Rule.ParityPartNum ones are parity blocks. The second returned value is payload sha256 hashes of the encoded parts.

All parts are the same length. If data len is not divisible by Rule.DataPartNum, last data part is aligned with zeros.

If data is empty, all parts are nil.

func FormObjectForECPart

func FormObjectForECPart(signer neofscrypto.Signer, parent object.Object, part []byte, partInfo PartInfo) (object.Object, error)

FormObjectForECPart forms object for EC part produced from given parent object.

func NodeSequenceForPart

func NodeSequenceForPart(partIdx, totalParts, nodes int) iter.Seq[int]

NodeSequenceForPart returns sorted sequence of node indexes to store object for EC part with index = partIdx produced by applying the rule such that Rule.DataPartNum + Rule.ParityPartNum = totalParts.

func ObjectWithAttributes

func ObjectWithAttributes(obj object.Object) bool

ObjectWithAttributes checks whether obj contains at least one EC attribute.

Types

type ErrParts

type ErrParts []oid.ID

ErrParts is error carrying ID set of EC parts.

func (ErrParts) Error

func (x ErrParts) Error() string

Error implements [error].

type PartInfo

type PartInfo struct {
	// Index of EC rule in the container storage policy.
	RuleIndex int
	// Part index.
	Index int
}

PartInfo groups information about single EC part produced according to some Rule.

func DecodePartInfoFromAttributes

func DecodePartInfoFromAttributes(ruleIdxAttr, partIdxAttr string) (PartInfo, error)

DecodePartInfoFromAttributes decodes EC part info from given object attributes. It one of attributes is set, the other must be set too. If both are missing, DecodePartInfoFromAttributes returns PartInfo.RuleIndex = -1 without error.

func GetPartInfo

func GetPartInfo(obj object.Object) (PartInfo, error)

GetPartInfo fetches EC part info from given object header. It one of object.AttributeECRuleIndex or object.AttributeECRuleIndex attributes is set, the other must be set too. If both are missing, GetPartInfo returns PartInfo.RuleIndex = -1 without error.

func GetRequiredPartInfo added in v0.50.0

func GetRequiredPartInfo(obj object.Object) (PartInfo, error)

GetRequiredPartInfo is like GetPartInfo but fails when object does not contain EC part attributes.

type Rule

type Rule struct {
	DataPartNum   uint8
	ParityPartNum uint8
}

Rule represents erasure coding rule for object payload's encoding and placement.

func (Rule) String

func (x Rule) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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