remove the unneeded connSecurityMultiaddrs interface

This commit is contained in:
Marten Seemann 2022-09-07 10:19:30 +03:00
parent ef657d6d7c
commit d2b47dd539
3 changed files with 7 additions and 12 deletions

View File

@ -10,12 +10,7 @@ import (
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
type connSecurityMultiaddrs interface { type connSecurityMultiaddrs struct {
network.ConnMultiaddrs
network.ConnSecurity
}
type connSecurityMultiaddrsImpl struct {
network.ConnSecurity network.ConnSecurity
network.ConnMultiaddrs network.ConnMultiaddrs
} }
@ -30,7 +25,7 @@ func (c *connMultiaddrs) LocalMultiaddr() ma.Multiaddr { return c.local }
func (c *connMultiaddrs) RemoteMultiaddr() ma.Multiaddr { return c.remote } func (c *connMultiaddrs) RemoteMultiaddr() ma.Multiaddr { return c.remote }
type conn struct { type conn struct {
connSecurityMultiaddrs *connSecurityMultiaddrs
transport tpt.Transport transport tpt.Transport
session *webtransport.Session session *webtransport.Session
@ -40,7 +35,7 @@ type conn struct {
var _ tpt.CapableConn = &conn{} var _ tpt.CapableConn = &conn{}
func newConn(tr tpt.Transport, sess *webtransport.Session, sconn connSecurityMultiaddrs, scope network.ConnScope) *conn { func newConn(tr tpt.Transport, sess *webtransport.Session, sconn *connSecurityMultiaddrs, scope network.ConnScope) *conn {
return &conn{ return &conn{
connSecurityMultiaddrs: sconn, connSecurityMultiaddrs: sconn,
transport: tr, transport: tr,

View File

@ -171,7 +171,7 @@ func (l *listener) Accept() (tpt.CapableConn, error) {
} }
} }
func (l *listener) handshake(ctx context.Context, sess *webtransport.Session) (connSecurityMultiaddrs, error) { func (l *listener) handshake(ctx context.Context, sess *webtransport.Session) (*connSecurityMultiaddrs, error) {
local, err := toWebtransportMultiaddr(sess.LocalAddr()) local, err := toWebtransportMultiaddr(sess.LocalAddr())
if err != nil { if err != nil {
return nil, fmt.Errorf("error determiniting local addr: %w", err) return nil, fmt.Errorf("error determiniting local addr: %w", err)
@ -194,7 +194,7 @@ func (l *listener) handshake(ctx context.Context, sess *webtransport.Session) (c
return nil, err return nil, err
} }
return &connSecurityMultiaddrsImpl{ return &connSecurityMultiaddrs{
ConnSecurity: c, ConnSecurity: c,
ConnMultiaddrs: &connMultiaddrs{local: local, remote: remote}, ConnMultiaddrs: &connMultiaddrs{local: local, remote: remote},
}, nil }, nil

View File

@ -179,7 +179,7 @@ func (t *transport) dial(ctx context.Context, addr string, certHashes []multihas
return sess, err return sess, err
} }
func (t *transport) upgrade(ctx context.Context, sess *webtransport.Session, p peer.ID, certHashes []multihash.DecodedMultihash) (connSecurityMultiaddrs, error) { func (t *transport) upgrade(ctx context.Context, sess *webtransport.Session, p peer.ID, certHashes []multihash.DecodedMultihash) (*connSecurityMultiaddrs, error) {
local, err := toWebtransportMultiaddr(sess.LocalAddr()) local, err := toWebtransportMultiaddr(sess.LocalAddr())
if err != nil { if err != nil {
return nil, fmt.Errorf("error determiniting local addr: %w", err) return nil, fmt.Errorf("error determiniting local addr: %w", err)
@ -215,7 +215,7 @@ func (t *transport) upgrade(ctx context.Context, sess *webtransport.Session, p p
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &connSecurityMultiaddrsImpl{ return &connSecurityMultiaddrs{
ConnSecurity: c, ConnSecurity: c,
ConnMultiaddrs: &connMultiaddrs{local: local, remote: remote}, ConnMultiaddrs: &connMultiaddrs{local: local, remote: remote},
}, nil }, nil