routing: extended DirectedNodePair functionality

This commit is contained in:
Joost Jager 2019-08-05 11:38:09 +02:00
parent 5c52efc0eb
commit b610f417d2
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -1,6 +1,8 @@
package routing package routing
import ( import (
"fmt"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
) )
@ -8,3 +10,21 @@ import (
type DirectedNodePair struct { type DirectedNodePair struct {
From, To route.Vertex 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}
}