Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
fix(bitswap) keep interface the same
Browse files Browse the repository at this point in the history
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

ipfs/kubo@ec50703
  • Loading branch information
Brian Tiger Chow committed Sep 22, 2014
1 parent 51d5dc0 commit 05265fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
11 changes: 3 additions & 8 deletions bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bitswap

import (
"errors"
"fmt"

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

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

go func() {
message := bsmsg.New()
message.AppendWanted(k)
for _, iiiii := range peersToQuery {
for iiiii := range peersToQuery {
// u.DOut("bitswap got peersToQuery: %s\n", iiiii)
go func(p *peer.Peer) {
response, err := bs.sender.SendRequest(ctx, p, message)
Expand Down
6 changes: 1 addition & 5 deletions network/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ type NetMessageService interface {
// TODO rename -> Router?
type Routing interface {
// FindProvidersAsync returns a channel of providers for the given key
// FindProvidersAsync(context.Context, u.Key, int) <-chan *peer.Peer
// ^--- removed this for now because has some bugs apparently.

// FindProviders returns the providers for the given key
FindProviders(context.Context, u.Key) ([]*peer.Peer, error)
FindProvidersAsync(context.Context, u.Key, int) <-chan *peer.Peer

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

0 comments on commit 05265fe

Please sign in to comment.