define a nostr.Kind type for event kinds, make adjustments everywhere and fix some horrible bugs with mmm, lmdb and badger querying and deleting.

This commit is contained in:
fiatjaf
2025-04-20 11:14:39 -03:00
parent 27f40c2cf2
commit 15c6093c9b
74 changed files with 689 additions and 404 deletions

View File

@@ -95,7 +95,7 @@ func Decode(bech32string string) (prefix string, value any, err error) {
if len(v) != 4 {
return prefix, nil, fmt.Errorf("invalid uint32 value for integer (%v)", v)
}
result.Kind = uint16(binary.BigEndian.Uint32(v))
result.Kind = nostr.Kind(binary.BigEndian.Uint32(v))
default:
// ignore
}
@@ -127,7 +127,7 @@ func Decode(bech32string string) (prefix string, value any, err error) {
}
result.PublicKey = nostr.PubKey(v)
case TLVKind:
result.Kind = uint16(binary.BigEndian.Uint32(v))
result.Kind = nostr.Kind(binary.BigEndian.Uint32(v))
default:
// ignore
}
@@ -185,7 +185,7 @@ func EncodeNevent(id nostr.ID, relays []string, author nostr.PubKey) string {
return nevent
}
func EncodeNaddr(pk nostr.PubKey, kind uint16, identifier string, relays []string) string {
func EncodeNaddr(pk nostr.PubKey, kind nostr.Kind, identifier string, relays []string) string {
buf := &bytes.Buffer{}
writeTLVEntry(buf, TLVDefault, []byte(identifier))