Skip to content

Commit c4b8f85

Browse files
committed
fixup! onionmessage: add BFS pathfinding for onion messages
1 parent d39f72b commit c4b8f85

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

onionmessage/pathfind.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,13 @@ func FindPath(ctx context.Context, graph graphdb.NodeTraverser, source,
150150
// ForEachNodeDirectedChannel callback when the destination is found.
151151
var errBFSDone = &bfsDoneError{}
152152

153+
// bfsDoneError is a custom error type that acts as a sentinel value to signal
154+
// that BFS traversal has reached the destination node. Using a distinct type
155+
// allows callers to identify this specific condition with errors.Is.
153156
type bfsDoneError struct{}
154157

158+
// Error satisfies the error interface, which is required for errBFSDone to be
159+
// used as a sentinel error value.
155160
func (e *bfsDoneError) Error() string { return "bfs done" }
156161

157162
// reconstructPath rebuilds the path from destination back to source using the

onionmessage/pathfind_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func newMockNodeTraverser() *mockNodeTraverser {
2828
}
2929
}
3030

31-
// addNode adds a node with the given features.
31+
// addNode adds a node with the given features to the mock graph.
3232
func (m *mockNodeTraverser) addNode(v route.Vertex,
3333
features *lnwire.FeatureVector) {
3434

0 commit comments

Comments
 (0)