Skip to content

Commit db25443

Browse files
committed
basichost: initial commit for protocol id compress
1 parent c99cb96 commit db25443

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

p2p/host/basic/basic_host.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I
477477
return nil, err
478478
}
479479

480+
if h.supportProtocolAbbreviation(p) {
481+
// TODO: if the protocol ID abbreviation is supported, do something here.
482+
}
483+
480484
if pref != "" {
481485
if err := s.SetProtocol(pref); err != nil {
482486
return nil, err
@@ -528,6 +532,17 @@ func (h *BasicHost) preferredProtocol(p peer.ID, pids []protocol.ID) (protocol.I
528532
return out, nil
529533
}
530534

535+
func (h *BasicHost) supportProtocolAbbreviation(p peer.ID) bool {
536+
mv, err := h.Peerstore().Get(p, "MaxMultiselectVersion")
537+
if err != nil {
538+
// if there is no value, assume it's not supported.
539+
return false
540+
}
541+
// TODO: Check the version with go-multistream
542+
_ = mv
543+
return false
544+
}
545+
531546
// Connect ensures there is a connection between this host and the peer with
532547
// given peer.ID. If there is not an active connection, Connect will issue a
533548
// h.Network.Dial, and block until a connection is open, or an error is returned.

0 commit comments

Comments
 (0)