Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
2c5fe90b
Unverified
Commit
2c5fe90b
authored
Aug 06, 2020
by
Janoš Guljaš
Committed by
GitHub
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retrieval: return chunk not found if max peers reached (#524)
parent
5ada5bcd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
retrieval.go
pkg/retrieval/retrieval.go
+5
-4
No files found.
pkg/retrieval/retrieval.go
View file @
2c5fe90b
...
@@ -7,9 +7,9 @@ package retrieval
...
@@ -7,9 +7,9 @@ package retrieval
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"github.com/ethersphere/bee/pkg/accounting"
"time"
"time"
"github.com/ethersphere/bee/pkg/accounting"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
...
@@ -85,11 +85,11 @@ const (
...
@@ -85,11 +85,11 @@ const (
retrieveChunkTimeout
=
10
*
time
.
Second
retrieveChunkTimeout
=
10
*
time
.
Second
)
)
func
(
s
*
Service
)
RetrieveChunk
(
ctx
context
.
Context
,
addr
swarm
.
Address
)
(
chunk
swarm
.
Chunk
,
err
error
)
{
func
(
s
*
Service
)
RetrieveChunk
(
ctx
context
.
Context
,
addr
swarm
.
Address
)
(
swarm
.
Chunk
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
maxPeers
*
retrieveChunkTimeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
maxPeers
*
retrieveChunkTimeout
)
defer
cancel
()
defer
cancel
()
v
,
err
,
_
:=
s
.
singleflight
.
Do
(
addr
.
String
(),
func
()
(
v
interface
{},
err
error
)
{
v
,
err
,
_
:=
s
.
singleflight
.
Do
(
addr
.
String
(),
func
()
(
interface
{},
error
)
{
var
skipPeers
[]
swarm
.
Address
var
skipPeers
[]
swarm
.
Address
for
i
:=
0
;
i
<
maxPeers
;
i
++
{
for
i
:=
0
;
i
<
maxPeers
;
i
++
{
var
peer
swarm
.
Address
var
peer
swarm
.
Address
...
@@ -105,7 +105,8 @@ func (s *Service) RetrieveChunk(ctx context.Context, addr swarm.Address) (chunk
...
@@ -105,7 +105,8 @@ func (s *Service) RetrieveChunk(ctx context.Context, addr swarm.Address) (chunk
s
.
logger
.
Tracef
(
"retrieval: got chunk %s from peer %s"
,
addr
,
peer
)
s
.
logger
.
Tracef
(
"retrieval: got chunk %s from peer %s"
,
addr
,
peer
)
return
chunk
,
nil
return
chunk
,
nil
}
}
return
nil
,
err
s
.
logger
.
Debugf
(
"retrieval: failed to get chunk %s: reached max peers of %v"
,
addr
,
maxPeers
)
return
nil
,
storage
.
ErrNotFound
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment