Add SQLite listing store with deterministic conflict rules

- Put verifies listings and keeps only the newest version per
  (author, id); equal seq resolves to the smaller hash so replicas converge
- Tombstones are stored so old versions cannot be resurrected
- Search by geohash prefix, kind, category, price, area, rooms
- Expire removes listings and tombstones past their lifetime

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 17:15:28 +01:00
co-authored by Claude Sonnet 5.5
parent 45abfdb03c
commit 08f6441f03
5 changed files with 708 additions and 11 deletions
+17 -11
View File
@@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"math/bits"
"strings"
"time"
"unicode"
"unicode/utf8"
@@ -301,21 +302,26 @@ func validGeohash(g string) error {
if len(g) != GeohashPrecision {
return fmt.Errorf("listing: geohash must have precision %d", GeohashPrecision)
}
for i := 0; i < len(g); i++ {
found := false
for j := 0; j < len(geohashAlphabet); j++ {
if g[i] == geohashAlphabet[j] {
found = true
break
}
}
if !found {
return errors.New("listing: invalid geohash character")
}
if !ValidGeohashPrefix(g) {
return errors.New("listing: invalid geohash character")
}
return nil
}
// ValidGeohashPrefix reports whether p is a non-empty geohash prefix of at
// most GeohashPrecision characters from the geohash alphabet.
func ValidGeohashPrefix(p string) bool {
if len(p) == 0 || len(p) > GeohashPrecision {
return false
}
for i := 0; i < len(p); i++ {
if !strings.ContainsRune(geohashAlphabet, rune(p[i])) {
return false
}
}
return true
}
func validPeerID(s string) bool {
if len(s) < 8 || len(s) > 128 {
return false