diff --git a/routing/nodepair.go b/routing/nodepair.go index edec8e02..43128e69 100644 --- a/routing/nodepair.go +++ b/routing/nodepair.go @@ -1,6 +1,8 @@ package routing import ( + "fmt" + "github.com/lightningnetwork/lnd/routing/route" ) @@ -8,3 +10,21 @@ import ( type DirectedNodePair struct { From, To route.Vertex } + +// NewDirectedNodePair instantiates a new DirectedNodePair struct. +func NewDirectedNodePair(from, to route.Vertex) DirectedNodePair { + return DirectedNodePair{ + From: from, + To: to, + } +} + +// String converts a node pair to its human readable representation. +func (d DirectedNodePair) String() string { + return fmt.Sprintf("%v -> %v", d.From, d.To) +} + +// Reverse returns a reversed copy of the pair. +func (d DirectedNodePair) Reverse() DirectedNodePair { + return DirectedNodePair{From: d.To, To: d.From} +}