mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-03 13:23:07 +00:00
discriminate stream errors from unsupported protocols
This commit is contained in:
parent
f31593e883
commit
6d2f8e649c
11
comm.go
11
comm.go
@ -11,6 +11,7 @@ import (
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
inet "github.com/libp2p/go-libp2p-net"
|
||||
peer "github.com/libp2p/go-libp2p-peer"
|
||||
ms "github.com/multiformats/go-multistream"
|
||||
)
|
||||
|
||||
// get the initial RPC containing all of our subscriptions to send to new peers
|
||||
@ -58,8 +59,16 @@ func (p *PubSub) handleNewPeer(ctx context.Context, pid peer.ID, outgoing <-chan
|
||||
s, err := p.host.NewStream(p.ctx, pid, p.rt.Protocols()...)
|
||||
if err != nil {
|
||||
log.Warning("opening new stream to peer: ", err, pid)
|
||||
|
||||
var ch chan peer.ID
|
||||
if err == ms.ErrNotSupported {
|
||||
ch = p.newPeerError
|
||||
} else {
|
||||
ch = p.peerDead
|
||||
}
|
||||
|
||||
select {
|
||||
case p.newPeerError <- pid:
|
||||
case ch <- pid:
|
||||
case <-ctx.Done():
|
||||
}
|
||||
return
|
||||
|
||||
@ -71,6 +71,12 @@
|
||||
"hash": "QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s",
|
||||
"name": "go-libp2p-crypto",
|
||||
"version": "2.0.4"
|
||||
},
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
"hash": "QmabLh8TrJ3emfAoQk5AbqbLTbMyj7XqumMFmAFxa9epo8",
|
||||
"name": "go-multistream",
|
||||
"version": "0.3.9"
|
||||
}
|
||||
],
|
||||
"gxVersion": "0.9.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user