From 3c61c77cad3cc7125e519be56d3f4b9b6f4f82e3 Mon Sep 17 00:00:00 2001 From: pippellia-btc Date: Thu, 29 May 2025 15:00:02 +0200 Subject: [PATCH] small cleanup --- pkg/graph/graph.go | 2 ++ pkg/redb/walks.go | 6 +++--- pkg/walks/walks.go | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/graph/graph.go b/pkg/graph/graph.go index 9344974..175f77f 100644 --- a/pkg/graph/graph.go +++ b/pkg/graph/graph.go @@ -1,3 +1,5 @@ +// The graph package defines the fundamental structures (e.g. [Node], [Delta]) +// that are used across packages. package graph import ( diff --git a/pkg/redb/walks.go b/pkg/redb/walks.go index 1b5776a..cbc872f 100644 --- a/pkg/redb/walks.go +++ b/pkg/redb/walks.go @@ -236,7 +236,7 @@ func (r RedisDB) ReplaceWalks(ctx context.Context, before, after []walks.Walk) e prev := before[i] next := after[i] - ID := string(after[i].ID) + ID := after[i].ID pipe.HSet(ctx, KeyWalks, ID, formatWalk(next)) @@ -343,13 +343,13 @@ func (r RedisDB) validateWalks() error { } // unique returns a slice of unique elements of the input slice. -func unique[S ~[]E, E cmp.Ordered](slice S) S { +func unique[E cmp.Ordered](slice []E) []E { if len(slice) == 0 { return nil } slices.Sort(slice) - unique := make(S, 0, len(slice)) + unique := make([]E, 0, len(slice)) unique = append(unique, slice[0]) for i := 1; i < len(slice); i++ { diff --git a/pkg/walks/walks.go b/pkg/walks/walks.go index cb58ab5..39198cf 100644 --- a/pkg/walks/walks.go +++ b/pkg/walks/walks.go @@ -20,6 +20,8 @@ var ( // ID represent how walks are identified in the storage layer type ID string +func (id ID) MarshalBinary() ([]byte, error) { return []byte(id), nil } + // Walk is an ordered list of node IDs type Walk struct { ID ID