badger/lmdb: fix tag sorting when they are small.

This commit is contained in:
fiatjaf
2023-12-10 07:42:26 -03:00
parent 0a8f93e886
commit 23451178ce
4 changed files with 20 additions and 5 deletions

View File

@@ -4,6 +4,8 @@ import (
"encoding/hex"
"strconv"
"strings"
"github.com/nbd-wtf/go-nostr"
)
func GetAddrTagElements(tagValue string) (kind uint16, pkb []byte, d string) {
@@ -17,3 +19,16 @@ func GetAddrTagElements(tagValue string) (kind uint16, pkb []byte, d string) {
}
return 0, nil, ""
}
func TagSorter(a, b nostr.Tag) int {
if len(a) < 2 {
if len(b) < 2 {
return 0
}
return -1
}
if len(b) < 2 {
return 1
}
return strings.Compare(a[1], b[1])
}