sdk: use a prefix iterator on kvdb for storing relay urls associated with ids.

This commit is contained in:
fiatjaf
2025-01-16 10:25:00 -03:00
parent e1971d12c0
commit 4cf9631c28
6 changed files with 108 additions and 10 deletions
+15
View File
@@ -56,3 +56,18 @@ func (s *Store) Close() error {
s.data = nil
return nil
}
func (s *Store) Scan(prefix []byte, fn func(key []byte, value []byte) bool) error {
s.RLock()
defer s.RUnlock()
prefixStr := string(prefix)
for k, v := range s.data {
if strings.HasPrefix(k, prefixStr) {
if !fn([]byte(k), v) {
break
}
}
}
return nil
}