lnwire: modify NetAddress to implement the net.Addr interface
This commit modifies lnwire.NetAddress by adding a .Network() method. With this added method the struct now implements the net.Addr interface meaning that it can now be transparently passed into any context where a net.Addr is requested. This change paves the way to integration of btcd’s new connmgr into the daemon to handle establishing persistent connections to all channel counter parties.
This commit is contained in:
parent
f37956e38e
commit
1855b95558
@ -38,11 +38,24 @@ type NetAddress struct {
|
||||
ChainNet wire.BitcoinNet
|
||||
}
|
||||
|
||||
// A compile time assertion to ensure that NetAddress meets the net.Addr
|
||||
// interface.
|
||||
var _ net.Addr = (*NetAddress)(nil)
|
||||
|
||||
// String returns a human readable string describing the target NetAddress. The
|
||||
// current string format is: <pubkey>@host.
|
||||
//
|
||||
// This part of the net.Addr interface.
|
||||
func (n *NetAddress) String() string {
|
||||
// TODO(roasbeef): use base58?
|
||||
pubkey := n.IdentityKey.SerializeCompressed()
|
||||
|
||||
return fmt.Sprintf("%x@%v", pubkey, n.Address)
|
||||
}
|
||||
|
||||
// Network returns the name of the network this address is binded to.
|
||||
//
|
||||
// This part of the net.Addr interface.
|
||||
func (n *NetAddress) Network() string {
|
||||
return n.Address.Network()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user