- pkg/encoders/event/codectester/divider/main.go - Added missing import for `orly.dev/pkg/utils`. - pkg/crypto/encryption/nip44.go - Imported `orly.dev/pkg/utils`. - pkg/crypto/ec/musig2/sign.go - Introduced `orly.dev/pkg/utils` import. - pkg/crypto/keys/keys.go - Included `orly.dev/pkg/utils`. - pkg/database/query-for-serials.go - Updated `QueryForSerials` to use `GetFullIdPubkeyBySerials` for batch retrieval. - Removed unnecessary `sort` package import. - Replaced outdated logic for serial resolution. - pkg/database/get-fullidpubkey-by-serials.go - Added new implementation for `GetFullIdPubkeyBySerials` for efficient batch serial lookups. - pkg/database/get-serial-by-id.go - Added placeholder for alternative serial lookup method. - pkg/database/database.go - Enabled `opts.Compression = options.None` in database configuration. - pkg/database/save-event.go - Replaced loop-based full ID lookup with `GetFullIdPubkeyBySerials` for efficiency. - pkg/database/get-serials-by-range.go - Added missing `sort.Slice` to enforce ascending order for serials. - pkg/crypto/ec/taproot/taproot.go - Imported `orly.dev/pkg/utils`. - pkg/crypto/ec/musig2/keys.go - Added `orly.dev/pkg/utils` import. - pkg/database/get-fullidpubkey-by-serial.go - Removed legacy `GetFullIdPubkeyBySerials` implementation. - pkg/database/query-for-ids.go - Refactored `QueryForIds` to use batched lookups via `GetFullIdPubkeyBySerials`. - Consolidated batch result deduplication logic. - Simplified code by removing redundant steps and checks.
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package database
|
|
|
|
import (
|
|
"bytes"
|
|
"github.com/dgraph-io/badger/v4"
|
|
"orly.dev/pkg/database/indexes"
|
|
"orly.dev/pkg/database/indexes/types"
|
|
"orly.dev/pkg/interfaces/store"
|
|
"orly.dev/pkg/utils/chk"
|
|
)
|
|
|
|
func (d *D) GetFullIdPubkeyBySerial(ser *types.Uint40) (
|
|
fidpk *store.IdPkTs, err error,
|
|
) {
|
|
if err = d.View(
|
|
func(txn *badger.Txn) (err error) {
|
|
buf := new(bytes.Buffer)
|
|
if err = indexes.FullIdPubkeyEnc(
|
|
ser, nil, nil, nil,
|
|
).MarshalWrite(buf); chk.E(err) {
|
|
return
|
|
}
|
|
prf := buf.Bytes()
|
|
it := txn.NewIterator(
|
|
badger.IteratorOptions{
|
|
Prefix: prf,
|
|
},
|
|
)
|
|
defer it.Close()
|
|
it.Seek(prf)
|
|
if it.Valid() {
|
|
item := it.Item()
|
|
key := item.Key()
|
|
ser, fid, p, ca := indexes.FullIdPubkeyVars()
|
|
buf2 := bytes.NewBuffer(key)
|
|
if err = indexes.FullIdPubkeyDec(
|
|
ser, fid, p, ca,
|
|
).UnmarshalRead(buf2); chk.E(err) {
|
|
return
|
|
}
|
|
idpkts := store.IdPkTs{
|
|
Id: fid.Bytes(),
|
|
Pub: p.Bytes(),
|
|
Ts: int64(ca.Get()),
|
|
Ser: ser.Get(),
|
|
}
|
|
fidpk = &idpkts
|
|
}
|
|
return
|
|
},
|
|
); chk.E(err) {
|
|
return
|
|
}
|
|
return
|
|
}
|