mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
fa0512f62f
In this commit, a new net.Addr implementation called OpaqueAddrs is added along with a WriteOpaqueAddrs func that is called in WriteNetAddrs. It will be used to store any address bytes that we cannot parse due to us not being aware of the address type.
35 lines
965 B
Go
35 lines
965 B
Go
package lnwire
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"net"
|
|
)
|
|
|
|
// OpaqueAddrs is used to store the address bytes for address types that are
|
|
// unknown to us.
|
|
type OpaqueAddrs struct {
|
|
Payload []byte
|
|
}
|
|
|
|
// A compile-time assertion to ensure that OpaqueAddrs meets the net.Addr
|
|
// interface.
|
|
var _ net.Addr = (*OpaqueAddrs)(nil)
|
|
|
|
// String returns a human-readable string describing the target OpaqueAddrs.
|
|
// Since this is an unknown address (and could even be multiple addresses), we
|
|
// just return the hex string of the payload.
|
|
//
|
|
// This part of the net.Addr interface.
|
|
func (o *OpaqueAddrs) String() string {
|
|
return hex.EncodeToString(o.Payload)
|
|
}
|
|
|
|
// Network returns the name of the network this address is bound to. Since this
|
|
// is an unknown address, we don't know the network and so just return a string
|
|
// indicating this.
|
|
//
|
|
// This part of the net.Addr interface.
|
|
func (o *OpaqueAddrs) Network() string {
|
|
return "unknown network for unrecognized address type"
|
|
}
|