Key and answer a ledger index by mesh-sdk's IndexKey and IndexEntry, the one shape the owner's watcher also writes (issue 1966 T3)

This commit is contained in:
2026-11-03 15:15:00 +01:00
parent d206b0dde1
commit fadc73f73b
5 changed files with 40 additions and 44 deletions
+3 -6
View File
@@ -1,12 +1,9 @@
package ledger
import (
"encoding/json"
"sort"
"strings"
"sync"
"git.novox.be/novox/mesh-sdk/go/buscalls"
)
// The memory stores keep what the bus keeps, as the bus answers it, for a test of a ledger without a bus: a stream whose
@@ -166,7 +163,7 @@ type MemoryIndex struct {
kv map[string][]byte
}
func (x *MemoryIndex) Entries(pattern string, limit int) ([]buscalls.IndexEntry, error) {
func (x *MemoryIndex) Entries(pattern string, limit int) ([]Indexed, error) {
x.mu.Lock()
defer x.mu.Unlock()
if pattern == "" {
@@ -179,12 +176,12 @@ func (x *MemoryIndex) Entries(pattern string, limit int) ([]buscalls.IndexEntry,
}
}
sort.Strings(keys)
var out []buscalls.IndexEntry
var out []Indexed
for _, k := range keys {
if limit > 0 && len(out) >= limit {
break
}
out = append(out, buscalls.IndexEntry{Key: k, Value: json.RawMessage(x.kv[k])})
out = append(out, Indexed{Key: k, Value: x.kv[k]})
}
return out, nil
}