Skip to content

Commit e441d61

Browse files
fix: address some comments
1 parent 12df606 commit e441d61

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

pkg/api/feed.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ func (s *Service) feedPostHandler(w http.ResponseWriter, r *http.Request) {
177177
}
178178

179179
headers := struct {
180-
BatchID []byte `map:"Swarm-Postage-Batch-Id" validate:"required"`
181-
Pin bool `map:"Swarm-Pin"`
182-
Deferred *bool `map:"Swarm-Deferred-Upload"`
183-
Act bool `map:"Swarm-Act"`
184-
HistoryAddress swarm.Address `map:"Swarm-Act-History-Address"`
185-
RedundancyLevel redundancy.Level `map:"Swarm-Redundancy-Level"`
180+
BatchID []byte `map:"Swarm-Postage-Batch-Id" validate:"required"`
181+
Pin bool `map:"Swarm-Pin"`
182+
Deferred *bool `map:"Swarm-Deferred-Upload"`
183+
Act bool `map:"Swarm-Act"`
184+
HistoryAddress swarm.Address `map:"Swarm-Act-History-Address"`
185+
RedundancyLevel *redundancy.Level `map:"Swarm-Redundancy-Level"`
186186
}{}
187187
if response := s.mapStructure(r.Header, &headers); response != nil {
188188
response("invalid header params", logger, w)
@@ -239,7 +239,10 @@ func (s *Service) feedPostHandler(w http.ResponseWriter, r *http.Request) {
239239
logger: logger,
240240
}
241241

242-
rLevel := headers.RedundancyLevel
242+
rLevel := redundancy.DefaultLevel
243+
if headers.RedundancyLevel != nil {
244+
rLevel = *headers.RedundancyLevel
245+
}
243246

244247
l := loadsave.New(s.storer.ChunkStore(), s.storer.Cache(), requestPipelineFactory(r.Context(), putter, false, 0), rLevel)
245248
feedManifest, err := manifest.NewDefaultManifest(l, false)

pkg/api/soc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (s *Service) socUploadHandler(w http.ResponseWriter, r *http.Request) {
7373
err error
7474
)
7575

76-
var rLevel redundancy.Level
76+
rLevel := redundancy.DefaultLevel
7777
if headers.RLevel != nil {
7878
rLevel = *headers.RLevel
7979
}

pkg/replicas/getter_soc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ func (g *socGetter) Get(ctx context.Context, addr swarm.Address) (ch swarm.Chunk
101101
continue
102102

103103
// getting the addresses in order
104-
case so := <-next:
105-
if so == nil {
104+
case so, ok := <-next:
105+
if !ok {
106106
next = nil
107107
continue
108108
}

pkg/replicas/putter_soc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package replicas
99
import (
1010
"context"
1111
"errors"
12+
"fmt"
1213

1314
"github.com/ethersphere/bee/v2/pkg/file/redundancy"
1415
"github.com/ethersphere/bee/v2/pkg/storage"
@@ -36,7 +37,7 @@ func (p *socPutter) Put(ctx context.Context, ch swarm.Chunk) error {
3637
errs := []error{}
3738
// Put base chunk first
3839
if err := p.putter.Put(ctx, ch); err != nil {
39-
return err
40+
return fmt.Errorf("soc putter: put base chunk: %w", err)
4041
}
4142
if p.rLevel == 0 {
4243
return nil

pkg/replicas/replicas.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ func newReplicator(addr swarm.Address, rLevel redundancy.Level) *replicator {
4141
rr := &replicator{
4242
addr: addr.Bytes(),
4343
sizes: redundancy.GetReplicaCounts(),
44-
c: make(chan *replica, 16),
44+
c: make(chan *replica, rLevel.GetReplicaCount()),
4545
rLevel: rLevel,
4646
}
47+
4748
go rr.replicas()
49+
4850
return rr
4951
}
5052

0 commit comments

Comments
 (0)