Skip to content

Commit 39ad222

Browse files
author
Brian Tiger Chow
committed
fix(bitswap) keep interface the same
changing the bitswap interace breaks tests and makes things a bit difficult going forward. I think I have a temporary solution to replace the async method. this commit partially reverts changes from: ec50703 ec50703
1 parent 2179b5d commit 39ad222

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

exchange/bitswap/bitswap.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package bitswap
22

33
import (
44
"errors"
5-
"fmt"
65

76
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
87
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
@@ -66,17 +65,13 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error)
6665
// TODO add to wantlist
6766
promise := bs.notifications.Subscribe(ctx, k)
6867

69-
// const maxProviders = 20
70-
// using non-async version for now.
71-
peersToQuery, err := bs.routing.FindProviders(ctx, k)
72-
if err != nil {
73-
return nil, fmt.Errorf("No providers found for %d (%v)", k, err)
74-
}
68+
const maxProviders = 20
69+
peersToQuery := bs.routing.FindProvidersAsync(ctx, k, maxProviders)
7570

7671
go func() {
7772
message := bsmsg.New()
7873
message.AppendWanted(k)
79-
for _, iiiii := range peersToQuery {
74+
for iiiii := range peersToQuery {
8075
// u.DOut("bitswap got peersToQuery: %s\n", iiiii)
8176
go func(p *peer.Peer) {
8277
response, err := bs.sender.SendRequest(ctx, p, message)

exchange/bitswap/network/interface.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ type NetMessageService interface {
4646
// TODO rename -> Router?
4747
type Routing interface {
4848
// FindProvidersAsync returns a channel of providers for the given key
49-
// FindProvidersAsync(context.Context, u.Key, int) <-chan *peer.Peer
50-
// ^--- removed this for now because has some bugs apparently.
51-
52-
// FindProviders returns the providers for the given key
53-
FindProviders(context.Context, u.Key) ([]*peer.Peer, error)
49+
FindProvidersAsync(context.Context, u.Key, int) <-chan *peer.Peer
5450

5551
// Provide provides the key to the network
5652
Provide(context.Context, u.Key) error

0 commit comments

Comments
 (0)