Skip to content

Commit 75dcaf0

Browse files
committed
feat: new soc putter session
1 parent 75ebfba commit 75dcaf0

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

pkg/api/soc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (s *Service) socUploadHandler(w http.ResponseWriter, r *http.Request) {
108108
})
109109
basePutter = putter
110110
if rLevel != redundancy.NONE {
111-
putter = replicas.NewSocPutter(putter, rLevel)
111+
putter = replicas.NewSocPutterSession(putter, rLevel)
112112
}
113113
}
114114
if err != nil {

pkg/replicas/putter_soc.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ import (
1212
"sync"
1313

1414
"github.com/ethersphere/bee/v2/pkg/file/redundancy"
15+
"github.com/ethersphere/bee/v2/pkg/storage"
1516
"github.com/ethersphere/bee/v2/pkg/storer"
1617
"github.com/ethersphere/bee/v2/pkg/swarm"
1718
)
1819

1920
// socPutter is the private implementation of the public storage.Putter interface
2021
// socPutter extends the original putter to a concurrent multiputter
2122
type socPutter struct {
22-
putter storer.PutterSession
23+
putter storage.Putter
2324
rLevel redundancy.Level
2425
}
2526

2627
// NewSocPutter is the putter constructor
27-
func NewSocPutter(p storer.PutterSession, rLevel redundancy.Level) storer.PutterSession {
28+
func NewSocPutter(p storage.Putter, rLevel redundancy.Level) storage.Putter {
2829
return &socPutter{
2930
putter: p,
3031
rLevel: rLevel,
@@ -65,10 +66,26 @@ func (p *socPutter) Put(ctx context.Context, ch swarm.Chunk) (err error) {
6566
return errors.Join(errs...)
6667
}
6768

68-
func (p *socPutter) Cleanup() error {
69-
return p.putter.Cleanup()
69+
// socPutterSession extends the original socPutter
70+
type socPutterSession struct {
71+
socPutter
72+
ps storer.PutterSession
7073
}
7174

72-
func (p *socPutter) Done(addr swarm.Address) error {
73-
return p.putter.Done(addr)
75+
// NewSocPutter is the putterSession constructor
76+
func NewSocPutterSession(p storer.PutterSession, rLevel redundancy.Level) storer.PutterSession {
77+
return &socPutterSession{
78+
socPutter{
79+
putter: p,
80+
rLevel: rLevel,
81+
}, p,
82+
}
83+
}
84+
85+
func (p *socPutterSession) Cleanup() error {
86+
return p.ps.Cleanup()
87+
}
88+
89+
func (p *socPutterSession) Done(addr swarm.Address) error {
90+
return p.ps.Done(addr)
7491
}

0 commit comments

Comments
 (0)