@@ -109,6 +109,8 @@ type maEndpoints struct {
109109 raddr ma.Multiaddr
110110}
111111
112+ var _ Conn = (* maConn )(nil )
113+
112114// LocalMultiaddr returns the local address associated with
113115// this connection
114116func (c * maEndpoints ) LocalMultiaddr () ma.Multiaddr {
@@ -310,14 +312,12 @@ func WrapNetListener(nl net.Listener) (Listener, error) {
310312// A PacketConn is a generic packet oriented network connection which uses an
311313// underlying net.PacketConn, wrapped with the locally bound Multiaddr.
312314type PacketConn interface {
313- Connection () net.PacketConn
314-
315- Multiaddr () ma.Multiaddr
315+ net.PacketConn
316316
317- ReadFrom (b []byte ) (int , ma.Multiaddr , error )
318- WriteTo (b []byte , maddr ma.Multiaddr ) (int , error )
317+ LocalMultiaddr () ma.Multiaddr
319318
320- Close () error
319+ ReadFromMultiaddr (b []byte ) (int , ma.Multiaddr , error )
320+ WriteToMultiaddr (b []byte , maddr ma.Multiaddr ) (int , error )
321321}
322322
323323// maPacketConn implements PacketConn
@@ -326,28 +326,25 @@ type maPacketConn struct {
326326 laddr ma.Multiaddr
327327}
328328
329- // Connection returns the embedded net.PacketConn.
330- func (l * maPacketConn ) Connection () net.PacketConn {
331- return l .PacketConn
332- }
329+ var _ PacketConn = (* maPacketConn )(nil )
333330
334- // Multiaddr returns the bound local Multiaddr.
335- func (l * maPacketConn ) Multiaddr () ma.Multiaddr {
331+ // LocalMultiaddr returns the bound local Multiaddr.
332+ func (l * maPacketConn ) LocalMultiaddr () ma.Multiaddr {
336333 return l .laddr
337334}
338335
339- func (l * maPacketConn ) ReadFrom (b []byte ) (int , ma.Multiaddr , error ) {
340- n , addr , err := l .PacketConn . ReadFrom (b )
336+ func (l * maPacketConn ) ReadFromMultiaddr (b []byte ) (int , ma.Multiaddr , error ) {
337+ n , addr , err := l .ReadFrom (b )
341338 maddr , _ := FromNetAddr (addr )
342339 return n , maddr , err
343340}
344341
345- func (l * maPacketConn ) WriteTo (b []byte , maddr ma.Multiaddr ) (int , error ) {
342+ func (l * maPacketConn ) WriteToMultiaddr (b []byte , maddr ma.Multiaddr ) (int , error ) {
346343 addr , err := ToNetAddr (maddr )
347344 if err != nil {
348345 return 0 , err
349346 }
350- return l .PacketConn . WriteTo (b , addr )
347+ return l .WriteTo (b , addr )
351348}
352349
353350// ListenPacket announces on the local network address laddr.
0 commit comments