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