Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(redundancy): on by default when downloading #4602

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/file/joiner/joiner.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (j *joiner) readAtOffset(
}

// fast forward the cursor
sec := j.subtrieSection(data, cursor, pSize, parity, subTrieSize)
sec := j.subtrieSection(cursor, pSize, parity, subTrieSize)
if cur+sec <= off {
cur += sec
continue
Expand Down Expand Up @@ -277,7 +277,7 @@ func (j *joiner) getShards(payloadSize, parities int) int {
}

// brute-forces the subtrie size for each of the sections in this intermediate chunk
func (j *joiner) subtrieSection(data []byte, startIdx, payloadSize, parities int, subtrieSize int64) int64 {
func (j *joiner) subtrieSection(startIdx, payloadSize, parities int, subtrieSize int64) int64 {
// assume we have a trie of size `y` then we can assume that all of
// the forks except for the last one on the right are of equal size
// this is due to how the splitter wraps levels.
Expand Down Expand Up @@ -375,7 +375,7 @@ func (j *joiner) processChunkAddresses(ctx context.Context, fn swarm.AddressIter
if j.refLength == encryption.ReferenceSize {
cursor += swarm.HashSize * min(i, shardCnt)
}
sec := j.subtrieSection(data, cursor, eSize, parity, subTrieSize)
sec := j.subtrieSection(cursor, eSize, parity, subTrieSize)
if sec <= swarm.ChunkSize {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/file/redundancy/getter/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (g *decoder) recover(ctx context.Context) error {
}

// decode using Reed-Solomon decoder
if err := g.decode(ctx); err != nil {
if err := g.decode(); err != nil {
return err
}

Expand All @@ -292,7 +292,7 @@ func (g *decoder) recover(ctx context.Context) error {

// decode uses Reed-Solomon erasure coding decoder to recover data shards
// it must be called after shqrdcnt shards are retrieved
func (g *decoder) decode(ctx context.Context) error {
func (g *decoder) decode() error {
g.mu.Lock()
defer g.mu.Unlock()

Expand Down
10 changes: 3 additions & 7 deletions pkg/file/redundancy/getter/strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package getter

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -15,8 +14,8 @@ import (
)

const (
DefaultStrategy = NONE // default prefetching strategy
DefaultStrict = true // default fallback modes
DefaultStrategy = DATA // default prefetching strategy
DefaultStrict = false // default fallback modes
DefaultFetchTimeout = retrieval.RetrieveChunkTimeout // timeout for each chunk retrieval
DefaultStrategyTimeout = 300 * time.Millisecond // timeout for each strategy
)
Expand Down Expand Up @@ -60,10 +59,7 @@ var DefaultConfig = Config{
func NewConfigFromContext(ctx context.Context, def Config) (conf Config, err error) {
var ok bool
conf = def
e := func(s string, errs ...error) error {
if len(errs) > 0 {
return fmt.Errorf("error setting %s from context: %w", s, errors.Join(errs...))
}
e := func(s string) error {
return fmt.Errorf("error setting %s from context", s)
}
if val := ctx.Value(strategyKey{}); val != nil {
Expand Down
Loading