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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user