Commit 847826d9 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

Revert "bitswap: network interface changed"

This reverts commit bf88f1aec5e3d397f97d64de52b52686cc7a8c8f.
parent c2186853
......@@ -176,16 +176,14 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.PeerInf
message.AddEntry(wanted.Key, wanted.Priority)
}
wg := sync.WaitGroup{}
for pi := range peers {
log.Debugf("bitswap.sendWantListTo: %s %s", pi.ID, pi.Addrs)
log.Event(ctx, "PeerToQuery", pi.ID)
for peerToQuery := range peers {
log.Event(ctx, "PeerToQuery", peerToQuery.ID)
wg.Add(1)
go func(pi peer.PeerInfo) {
go func(p peer.ID) {
defer wg.Done()
p := pi.ID
log.Event(ctx, "DialPeer", p)
err := bs.sender.DialPeer(ctx, pi)
err := bs.sender.DialPeer(ctx, p)
if err != nil {
log.Errorf("Error sender.DialPeer(%s): %s", p, err)
return
......@@ -200,7 +198,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.PeerInf
// communication fails. May require slightly different API to
// get better guarantees. May need shared sequence numbers.
bs.engine.MessageSent(p, message)
}(pi)
}(peerToQuery.ID)
}
wg.Wait()
return nil
......
......@@ -12,7 +12,7 @@ import (
type BitSwapNetwork interface {
// DialPeer ensures there is a connection to peer.
DialPeer(context.Context, peer.PeerInfo) error
DialPeer(context.Context, peer.ID) error
// SendMessage sends a BitSwap message to a peer.
SendMessage(
......
......@@ -53,9 +53,8 @@ func (bsnet *impl) handleNewStream(s inet.Stream) {
}
func (bsnet *impl) DialPeer(ctx context.Context, p peer.PeerInfo) error {
bsnet.network.Peerstore().AddAddresses(p.ID, p.Addrs)
return bsnet.network.DialPeer(ctx, p.ID)
func (bsnet *impl) DialPeer(ctx context.Context, p peer.ID) error {
return bsnet.network.DialPeer(ctx, p)
}
func (bsnet *impl) SendMessage(
......
......@@ -165,10 +165,10 @@ func (nc *networkClient) SendRequest(
return nc.network.SendRequest(ctx, nc.local, to, message)
}
func (nc *networkClient) DialPeer(ctx context.Context, p peer.PeerInfo) error {
func (nc *networkClient) DialPeer(ctx context.Context, p peer.ID) error {
// no need to do anything because dialing isn't a thing in this test net.
if !nc.network.HasPeer(p.ID) {
return fmt.Errorf("Peer not in network: %s", p.ID)
if !nc.network.HasPeer(p) {
return fmt.Errorf("Peer not in network: %s", p)
}
return nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment