Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
49ccd212
Commit
49ccd212
authored
Jun 29, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: make sure to leave time to send provider records
parent
e257c225
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
routing.go
routing.go
+22
-1
No files found.
routing.go
View file @
49ccd212
...
...
@@ -408,7 +408,28 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err
return
nil
}
peers
,
err
:=
dht
.
GetClosestPeers
(
ctx
,
key
.
KeyString
())
closerCtx
:=
ctx
if
deadline
,
ok
:=
ctx
.
Deadline
();
ok
{
now
:=
time
.
Now
()
timeout
:=
deadline
.
Sub
(
now
)
if
timeout
<
0
{
// timed out
return
context
.
DeadlineExceeded
}
else
if
timeout
<
10
*
time
.
Second
{
// Reserve 10% for the final put.
deadline
=
deadline
.
Add
(
timeout
/
10
)
}
else
{
// Otherwise, reserve a second (we'll already be
// connected so this should be fast).
deadline
=
deadline
.
Add
(
-
time
.
Second
)
}
var
cancel
context
.
CancelFunc
closerCtx
,
cancel
=
context
.
WithDeadline
(
ctx
,
deadline
)
defer
cancel
()
}
peers
,
err
:=
dht
.
GetClosestPeers
(
closerCtx
,
key
.
KeyString
())
if
err
!=
nil
{
return
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