func (bsnet *impl) SendMessage( ctx context.Context, p peer.ID, outgoing bsmsg.BitSwapMessage) error { s, err := bsnet.newStreamToPeer(ctx, p) if err != nil { return err } defer s.Close() if err := outgoing.ToNet(s); err != nil { log.Debugf("error: %s", err) return err } return err }
func (bsnet *impl) SendRequest( ctx context.Context, p peer.ID, outgoing bsmsg.BitSwapMessage) (bsmsg.BitSwapMessage, error) { s, err := bsnet.newStreamToPeer(ctx, p) if err != nil { return nil, err } defer s.Close() if err := outgoing.ToNet(s); err != nil { log.Debugf("error: %s", err) return nil, err } incoming, err := bsmsg.FromNet(s) if err != nil { log.Debugf("error: %s", err) return incoming, err } return incoming, nil }