fb10815229
* add outline for ECRepairer * add description of process in TODO comments * begin download/getting hash for a single piece * verify piece hash and order limit during download * fix download piece * begin filling out ESREpair. Get * wip move ecclient.Repair to ecrepairer.Repair * pass satellite signee into repairer * reconstruct original stripe from pieces * move rebuildStripe() * calculate piece size differently, increment successful count * fix shares slices initialization * rename stripeData to segment * do not pad reader in Repair() * temp debug * create unsafeRSScheme * use decode reader * rename file name to be all lowercase * make repair downloader async * declare condition variable inside Get method * set downloadAndVerifyPiece's in-memory buffer to be share size * update unusedLimits var * address comments * remove unnecessary comments * move initialization of segmentRepaire to be outside of repairer service * use ReadAll during download * remove dots and move hashing to after validating for order limit signature * wip test * make sure files exactly at min threshold are repaired * remove unused code * use corrput data and write back to storagenode * only create corrupted node and piece ids once * add comment * address nat's comment * fix linting and checker_test * update comment * add comments * remove "copied from ecclient" comments * add clarification comments in ec.Repair
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package eestream
|
|
|
|
import (
|
|
"github.com/vivint/infectious"
|
|
)
|
|
|
|
type unsafeRSScheme struct {
|
|
fc *infectious.FEC
|
|
erasureShareSize int
|
|
}
|
|
|
|
// NewUnsafeRSScheme returns a Reed-Solomon-based ErasureScheme without error correction.
|
|
func NewUnsafeRSScheme(fc *infectious.FEC, erasureShareSize int) ErasureScheme {
|
|
return &unsafeRSScheme{fc: fc, erasureShareSize: erasureShareSize}
|
|
}
|
|
|
|
func (s *unsafeRSScheme) EncodeSingle(input, output []byte, num int) (err error) {
|
|
return s.fc.EncodeSingle(input, output, num)
|
|
}
|
|
|
|
func (s *unsafeRSScheme) Encode(input []byte, output func(num int, data []byte)) (
|
|
err error) {
|
|
return s.fc.Encode(input, func(s infectious.Share) {
|
|
output(s.Number, s.Data)
|
|
})
|
|
}
|
|
|
|
func (s *unsafeRSScheme) Decode(out []byte, in map[int][]byte) ([]byte, error) {
|
|
shares := make([]infectious.Share, 0, len(in))
|
|
for num, data := range in {
|
|
shares = append(shares, infectious.Share{Number: num, Data: data})
|
|
}
|
|
|
|
stripe := make([]byte, s.RequiredCount()*s.ErasureShareSize())
|
|
err := s.fc.Rebuild(shares, func(share infectious.Share) {
|
|
copy(stripe[share.Number*s.ErasureShareSize():], share.Data)
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return stripe, nil
|
|
}
|
|
|
|
func (s *unsafeRSScheme) ErasureShareSize() int {
|
|
return s.erasureShareSize
|
|
}
|
|
|
|
func (s *unsafeRSScheme) StripeSize() int {
|
|
return s.erasureShareSize * s.fc.Required()
|
|
}
|
|
|
|
func (s *unsafeRSScheme) TotalCount() int {
|
|
return s.fc.Total()
|
|
}
|
|
|
|
func (s *unsafeRSScheme) RequiredCount() int {
|
|
return s.fc.Required()
|
|
}
|