Commit 96e4204f authored by Jeromy's avatar Jeromy

switch over to using sendMessage vs sendRequest

parent 27193bde
...@@ -151,6 +151,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e ...@@ -151,6 +151,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e
message.AddWanted(wanted) message.AddWanted(wanted)
} }
for peerToQuery := range peers { for peerToQuery := range peers {
log.Debug("sending query to: %s", peerToQuery)
log.Event(ctx, "PeerToQuery", peerToQuery) log.Event(ctx, "PeerToQuery", peerToQuery)
go func(p peer.Peer) { go func(p peer.Peer) {
...@@ -161,20 +162,15 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e ...@@ -161,20 +162,15 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e
return return
} }
response, err := bs.sender.SendRequest(ctx, p, message) err = bs.sender.SendMessage(ctx, p, message)
if err != nil { if err != nil {
log.Errorf("Error sender.SendRequest(%s) = %s", p, err) log.Errorf("Error sender.SendMessage(%s) = %s", p, err)
return return
} }
// FIXME ensure accounting is handled correctly when // FIXME ensure accounting is handled correctly when
// communication fails. May require slightly different API to // communication fails. May require slightly different API to
// get better guarantees. May need shared sequence numbers. // get better guarantees. May need shared sequence numbers.
bs.strategy.MessageSent(p, message) bs.strategy.MessageSent(p, message)
if response == nil {
return
}
bs.ReceiveMessage(ctx, p, response)
}(peerToQuery) }(peerToQuery)
} }
return nil return nil
......
...@@ -48,21 +48,8 @@ func (bsnet *impl) HandleMessage( ...@@ -48,21 +48,8 @@ func (bsnet *impl) HandleMessage(
return nil return nil
} }
p, bsmsg := bsnet.receiver.ReceiveMessage(ctx, incoming.Peer(), received) bsnet.receiver.ReceiveMessage(ctx, incoming.Peer(), received)
return nil
// TODO(brian): put this in a helper function
if bsmsg == nil || p == nil {
return nil
}
outgoing, err := bsmsg.ToNet(p)
if err != nil {
go bsnet.receiver.ReceiveError(err)
return nil
}
log.Debugf("Message size: %d", len(outgoing.Data()))
return outgoing
} }
func (bsnet *impl) DialPeer(ctx context.Context, p peer.Peer) error { func (bsnet *impl) DialPeer(ctx context.Context, p peer.Peer) error {
......
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