@cryptotaxi247 / kubo / commits / 39ad222da

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: ec50703395098f75946f0bad01816cc54ab18a58 https://github.com/jbenet/go-ipfs/commit/ec50703395098f75946f0bad01816cc54ab18a58

Brian Tiger Chow committed Sep 21, 2014 at 22:00 UTC 39ad222da9b63642a3826971bcdcefa1ce06e425
2 files changed +4 -13
exchange/bitswap/bitswap.go
+3 -8
@@ -2,7 +2,6 @@ package bitswap
2
3 import (
4 "errors"
5 - "fmt"
5
6 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7 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)
65 // TODO add to wantlist
66 promise := bs.notifications.Subscribe(ctx, k)
67
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)
70
71 go func() {
72 message := bsmsg.New()
73 message.AppendWanted(k)
79 - for _, iiiii := range peersToQuery {
74 + for iiiii := range peersToQuery {
75 // u.DOut("bitswap got peersToQuery: %s\n", iiiii)
76 go func(p *peer.Peer) {
77 response, err := bs.sender.SendRequest(ctx, p, message)
exchange/bitswap/network/interface.go
+1 -5
@@ -46,11 +46,7 @@ type NetMessageService interface {
46 // TODO rename -> Router?
47 type Routing interface {
48 // 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
50
51 // Provide provides the key to the network
52 Provide(context.Context, u.Key) error