From f5d23a3b515bd5081a34dc80bea0fd6b70acbc84 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 18 Jan 2024 17:55:08 -0300 Subject: [PATCH] lmdb/badger: stop sorting tags in-place when creating indexes. it is not necessary and was messing up things. --- badger/helpers.go | 1 - lmdb/helpers.go | 1 - utils.go | 15 --------------- 3 files changed, 17 deletions(-) diff --git a/badger/helpers.go b/badger/helpers.go index dc70ddb..0be2073 100644 --- a/badger/helpers.go +++ b/badger/helpers.go @@ -86,7 +86,6 @@ func getIndexKeysForEvent(evt *nostr.Event, idx []byte) [][]byte { } // ~ by tagvalue+date - slices.SortFunc(evt.Tags, eventstore.TagSorter) for i, tag := range evt.Tags { if len(tag) < 2 || len(tag[0]) != 1 || len(tag[1]) == 0 || len(tag[1]) > 100 { // not indexable diff --git a/lmdb/helpers.go b/lmdb/helpers.go index fef9dbb..7fb2378 100644 --- a/lmdb/helpers.go +++ b/lmdb/helpers.go @@ -79,7 +79,6 @@ func (b *LMDBBackend) getIndexKeysForEvent(evt *nostr.Event) []key { } // ~ by tagvalue+date - slices.SortFunc(evt.Tags, eventstore.TagSorter) for i, tag := range evt.Tags { if len(tag) < 2 || len(tag[0]) != 1 || len(tag[1]) == 0 || len(tag[1]) > 100 { // not indexable diff --git a/utils.go b/utils.go index 6c4d87f..3718cc4 100644 --- a/utils.go +++ b/utils.go @@ -4,8 +4,6 @@ import ( "encoding/hex" "strconv" "strings" - - "github.com/nbd-wtf/go-nostr" ) func GetAddrTagElements(tagValue string) (kind uint16, pkb []byte, d string) { @@ -19,16 +17,3 @@ 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]) -}