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
dms3
go-unixfs
Commits
0bd8f209
Commit
0bd8f209
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refac(routing) replace timeout -> ctx
@jbenet oh hai there!
parent
81da645e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
exchange/bitswap/bitswap.go
exchange/bitswap/bitswap.go
+2
-2
routing/dht/routing.go
routing/dht/routing.go
+1
-3
routing/routing.go
routing/routing.go
+3
-1
No files found.
exchange/bitswap/bitswap.go
View file @
0bd8f209
...
...
@@ -22,7 +22,7 @@ import (
type
Routing
interface
{
// FindProvidersAsync returns a channel of providers for the given key
// TODO replace with timeout with context
FindProvidersAsync
(
u
.
Key
,
int
,
time
.
Duration
)
<-
chan
*
peer
.
Peer
FindProvidersAsync
(
context
.
Context
,
u
.
Key
,
int
)
<-
chan
*
peer
.
Peer
// Provide provides the key to the network
Provide
(
key
u
.
Key
)
error
...
...
@@ -74,7 +74,7 @@ func (bs *bitswap) Block(k u.Key, timeout time.Duration) (
// TODO replace timeout with ctx in routing interface
begin
:=
time
.
Now
()
tleft
:=
timeout
-
time
.
Now
()
.
Sub
(
begin
)
provs_ch
:=
bs
.
routing
.
FindProvidersAsync
(
k
,
20
,
timeout
)
provs_ch
:=
bs
.
routing
.
FindProvidersAsync
(
ctx
,
k
,
20
)
blockChannel
:=
make
(
chan
blocks
.
Block
)
after
:=
time
.
After
(
tleft
)
...
...
This diff is collapsed.
Click to expand it.
routing/dht/routing.go
View file @
0bd8f209
...
...
@@ -121,9 +121,7 @@ func (dht *IpfsDHT) Provide(key u.Key) error {
}
// FindProvidersAsync runs FindProviders and sends back results over a channel
func
(
dht
*
IpfsDHT
)
FindProvidersAsync
(
key
u
.
Key
,
count
int
,
timeout
time
.
Duration
)
<-
chan
*
peer
.
Peer
{
ctx
,
_
:=
context
.
WithTimeout
(
context
.
TODO
(),
timeout
)
func
(
dht
*
IpfsDHT
)
FindProvidersAsync
(
ctx
context
.
Context
,
key
u
.
Key
,
count
int
)
<-
chan
*
peer
.
Peer
{
peerOut
:=
make
(
chan
*
peer
.
Peer
,
count
)
go
func
()
{
ps
:=
newPeerSet
()
...
...
This diff is collapsed.
Click to expand it.
routing/routing.go
View file @
0bd8f209
...
...
@@ -3,6 +3,8 @@ package routing
import
(
"time"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -10,7 +12,7 @@ import (
// IpfsRouting is the routing module interface
// It is implemented by things like DHTs, etc.
type
IpfsRouting
interface
{
FindProvidersAsync
(
u
.
Key
,
int
,
time
.
Duration
)
<-
chan
*
peer
.
Peer
FindProvidersAsync
(
context
.
Context
,
u
.
Key
,
int
)
<-
chan
*
peer
.
Peer
// Basic Put/Get
...
...
This diff is collapsed.
Click to expand it.
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