routing: extended DirectedNodePair functionality
This commit is contained in:
parent
5c52efc0eb
commit
b610f417d2
@ -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}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user